|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | + Module: Unit tests for parsing classes with generic superclasses or interfaces |
| 4 | + with unsupported signatures, falling back to using the raw type |
| 5 | + descriptors |
| 6 | +
|
| 7 | + Author: DiffBlue Limited. All rights reserved. |
| 8 | +
|
| 9 | +\*******************************************************************/ |
| 10 | + |
| 11 | +#include <testing-utils/catch.hpp> |
| 12 | +#include <testing-utils/load_java_class.h> |
| 13 | +#include <testing-utils/require_type.h> |
| 14 | + |
| 15 | +SCENARIO( |
| 16 | + "parse generic superclass signature", |
| 17 | + "[core][java_byte code[java_bytecode_parse_generics]]") |
| 18 | +{ |
| 19 | + const symbol_tablet &new_symbol_table = load_java_class( |
| 20 | + "GenericBounds", "./java_bytecode/java_bytecode_parse_generics"); |
| 21 | + |
| 22 | + const std::string base_generic = "java::Generic"; |
| 23 | + const irep_idt base_generic_interface = "java::InterfaceGeneric"; |
| 24 | + |
| 25 | + const std::string load_class("java::GenericBounds"); |
| 26 | + THEN( |
| 27 | + "these fields have a non-generic base class / interface as their real " |
| 28 | + "generic signature is unsupported at the moment") |
| 29 | + { |
| 30 | + // once bounds in generic signatures are supported, this test must be |
| 31 | + // changed to check for the correct generic types, TODO(mgudemann), |
| 32 | + // cf. TG-1286, TG-675 |
| 33 | + { |
| 34 | + const symbolt &upper_symbol = |
| 35 | + new_symbol_table.lookup_ref("java::GenericBoundsUpper"); |
| 36 | + const java_class_typet &upper_type = |
| 37 | + to_java_class_type(upper_symbol.type); |
| 38 | + REQUIRE(upper_type.bases().size() == 1); |
| 39 | + const symbol_typet base_type = require_type::require_symbol( |
| 40 | + upper_type.bases().at(0).type(), base_generic); |
| 41 | + REQUIRE_FALSE(is_java_generic_symbol_type(base_type)); |
| 42 | + } |
| 43 | + { |
| 44 | + const symbolt &lower_symbol = |
| 45 | + new_symbol_table.lookup_ref("java::GenericBoundsLower"); |
| 46 | + const java_class_typet &lower_type = |
| 47 | + to_java_class_type(lower_symbol.type); |
| 48 | + REQUIRE(lower_type.bases().size() == 1); |
| 49 | + const symbol_typet base_type = require_type::require_symbol( |
| 50 | + lower_type.bases().at(0).type(), base_generic); |
| 51 | + REQUIRE_FALSE(is_java_generic_symbol_type(base_type)); |
| 52 | + } |
| 53 | + { |
| 54 | + const symbolt &interface_symbol = |
| 55 | + new_symbol_table.lookup_ref("java::GenericInterface"); |
| 56 | + const java_class_typet &interface_type = |
| 57 | + to_java_class_type(interface_symbol.type); |
| 58 | + REQUIRE(interface_type.bases().size() == 2); |
| 59 | + const symbol_typet base_type = require_type::require_symbol( |
| 60 | + interface_type.bases().at(1).type(), base_generic_interface); |
| 61 | + REQUIRE_FALSE(is_java_generic_symbol_type(base_type)); |
| 62 | + } |
| 63 | + } |
| 64 | +} |
0 commit comments