88
99#include < catch.hpp>
1010
11+ #include < java_bytecode/java_types.h>
1112#include < util/arith_tools.h>
1213#include < util/c_types.h>
14+ #include < util/config.h>
1315#include < util/namespace.h>
1416#include < util/pointer_predicates.h>
1517#include < util/simplify_expr.h>
1820
1921TEST_CASE (" Simplify pointer_offset(address of array index)" )
2022{
23+ config.set_arch (" none" );
24+
2125 symbol_tablet symbol_table;
2226 namespacet ns (symbol_table);
2327
@@ -38,6 +42,8 @@ TEST_CASE("Simplify pointer_offset(address of array index)")
3842
3943TEST_CASE (" Simplify const pointer offset" )
4044{
45+ config.set_arch (" none" );
46+
4147 symbol_tablet symbol_table;
4248 namespacet ns (symbol_table);
4349
@@ -54,3 +60,23 @@ TEST_CASE("Simplify const pointer offset")
5460 REQUIRE (!to_integer (simp, offset_value));
5561 REQUIRE (offset_value==1234 );
5662}
63+
64+ TEST_CASE (" Simplify Java boolean -> int -> boolean casts" )
65+ {
66+ config.set_arch (" none" );
67+
68+ const exprt simplified=simplify_expr (
69+ typecast_exprt (
70+ typecast_exprt (
71+ symbol_exprt (
72+ " foo" ,
73+ java_boolean_type ()),
74+ java_int_type ()),
75+ java_boolean_type ()),
76+ namespacet (symbol_tablet ()));
77+
78+ REQUIRE (simplified.id ()==ID_symbol);
79+ REQUIRE (simplified.type ()==java_boolean_type ());
80+ const auto &symbol=to_symbol_expr (simplified);
81+ REQUIRE (symbol.get_identifier ()==" foo" );
82+ }
0 commit comments