Skip to content

Commit 1d87928

Browse files
committed
Add unit test for new behavior
1 parent 9ea7414 commit 1d87928

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

unit/util/simplify_expr.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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>
1314
#include <util/config.h>
@@ -59,3 +60,23 @@ TEST_CASE("Simplify const pointer offset")
5960
REQUIRE(!to_integer(simp, offset_value));
6061
REQUIRE(offset_value==1234);
6162
}
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

Comments
 (0)