|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | + Module: Unit tests for converting constructors and static initializers |
| 4 | +
|
| 5 | + Author: Diffblue Limited. |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include <testing-utils/catch.hpp> |
| 10 | + |
| 11 | +#include <util/symbol_table.h> |
| 12 | + |
| 13 | +#include <java-testing-utils/load_java_class.h> |
| 14 | +#include <java-testing-utils/require_type.h> |
| 15 | + |
| 16 | +SCENARIO( |
| 17 | + "java_bytecode_convert_bridge_method", |
| 18 | + "[core][java_bytecode][java_bytecode_convert_method]") |
| 19 | +{ |
| 20 | + GIVEN("A class with a bridge method") |
| 21 | + { |
| 22 | + const symbol_tablet symbol_table = load_java_class( |
| 23 | + "ClassWithBridgeMethod", "./java_bytecode/java_bytecode_convert_method"); |
| 24 | + |
| 25 | + const std::string method_name = "java::ClassWithBridgeMethod.compareTo"; |
| 26 | + |
| 27 | + WHEN("When parsing the bridge method") |
| 28 | + { |
| 29 | + const symbolt function_symbol = |
| 30 | + symbol_table.lookup_ref(method_name + ":(Ljava/lang/Object;)I"); |
| 31 | + |
| 32 | + const code_typet &function_type = |
| 33 | + require_type::require_code(function_symbol.type); |
| 34 | + THEN("The method should be marked as a bridge method") |
| 35 | + { |
| 36 | + REQUIRE(function_type.get_bool(ID_is_bridge_method)); |
| 37 | + } |
| 38 | + } |
| 39 | + WHEN("When parsing a non-bridge method") |
| 40 | + { |
| 41 | + THEN("THe method should not be marked as a bridge method") |
| 42 | + { |
| 43 | + const symbolt function_symbol = |
| 44 | + symbol_table.lookup_ref(method_name + ":(LClassWithBridgeMethod;)I"); |
| 45 | + |
| 46 | + const code_typet &function_type = |
| 47 | + require_type::require_code(function_symbol.type); |
| 48 | + THEN("The method should be marked as a bridge method") |
| 49 | + { |
| 50 | + REQUIRE_FALSE(function_type.get_bool(ID_is_bridge_method)); |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments