|
1 | 1 | /*******************************************************************\ |
2 | 2 |
|
3 | | - Module: Unit tests for converting constructors and static initializers |
| 3 | + Module: Unit tests for classes with bridge methods and native methods |
4 | 4 |
|
5 | 5 | Author: Diffblue Limited. |
6 | 6 |
|
@@ -56,4 +56,43 @@ SCENARIO( |
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
| 59 | + GIVEN("A class with a native method") |
| 60 | + { |
| 61 | + const symbol_tablet symbol_table = load_java_class( |
| 62 | + "ClassWithNativeMethod", "./java_bytecode/java_bytecode_convert_method"); |
| 63 | + |
| 64 | + const std::string method_name = "java::ClassWithNativeMethod.f"; |
| 65 | + |
| 66 | + WHEN("When parsing the native method") |
| 67 | + { |
| 68 | + const symbolt function_symbol = |
| 69 | + symbol_table.lookup_ref(method_name + ":()Z"); |
| 70 | + |
| 71 | + const java_method_typet &function_type = |
| 72 | + require_type::require_java_method(function_symbol.type); |
| 73 | + THEN("The method symbol should be of java_method_typet") |
| 74 | + { |
| 75 | + REQUIRE(function_type.get_bool(ID_C_java_method_type)); |
| 76 | + } |
| 77 | + THEN("And the method should be marked as a native method") |
| 78 | + { |
| 79 | + REQUIRE(to_java_method_type(function_type).is_native()); |
| 80 | + } |
| 81 | + } |
| 82 | + WHEN("When parsing a non-native method") |
| 83 | + { |
| 84 | + THEN("THe method should not be marked as a native method") |
| 85 | + { |
| 86 | + const symbolt function_symbol = |
| 87 | + symbol_table.lookup_ref(method_name + ":(I)Z"); |
| 88 | + |
| 89 | + const java_method_typet &function_type = |
| 90 | + require_type::require_java_method(function_symbol.type); |
| 91 | + THEN("The method should be marked as a native method") |
| 92 | + { |
| 93 | + REQUIRE_FALSE(to_java_method_type(function_type).is_native()); |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + } |
59 | 98 | } |
0 commit comments