|
7 | 7 |
|
8 | 8 | \*******************************************************************/
|
9 | 9 |
|
| 10 | +#include <map> |
| 11 | +#include <string> |
| 12 | + |
10 | 13 | #include <testing-utils/catch.hpp>
|
11 | 14 | #include <testing-utils/load_java_class.h>
|
12 | 15 | #include <testing-utils/require_type.h>
|
@@ -179,7 +182,7 @@ SCENARIO(
|
179 | 182 | // We want to test that the specialized/instantiated class has it's field
|
180 | 183 | // type updated, so find the specialized class, not the generic class.
|
181 | 184 | const irep_idt test_class =
|
182 |
| - "java::generic_field_array_instantiation$generic<java::array[reference]" |
| 185 | + "java::generic_field_array_instantiation$generic<array[reference]" |
183 | 186 | "of_java::java.lang.Float>";
|
184 | 187 |
|
185 | 188 | GIVEN("A generic type instantiated with an array type")
|
@@ -224,15 +227,15 @@ SCENARIO(
|
224 | 227 | GIVEN("A generic type instantiated with different array types")
|
225 | 228 | {
|
226 | 229 | const irep_idt test_class_integer =
|
227 |
| - "java::generic_field_array_instantiation$generic<java::array[reference]" |
| 230 | + "java::generic_field_array_instantiation$generic<array[reference]" |
228 | 231 | "of_"
|
229 | 232 | "java::java.lang.Integer>";
|
230 | 233 |
|
231 | 234 | const irep_idt test_class_int =
|
232 |
| - "java::generic_field_array_instantiation$generic<java::array[int]>"; |
| 235 | + "java::generic_field_array_instantiation$generic<array[int]>"; |
233 | 236 |
|
234 | 237 | const irep_idt test_class_float =
|
235 |
| - "java::generic_field_array_instantiation$generic<java::array[float]>"; |
| 238 | + "java::generic_field_array_instantiation$generic<array[float]>"; |
236 | 239 |
|
237 | 240 | const struct_typet::componentt &component_g =
|
238 | 241 | require_type::require_component(
|
@@ -330,7 +333,7 @@ SCENARIO(
|
330 | 333 | "table")
|
331 | 334 | {
|
332 | 335 | const std::string specialised_string =
|
333 |
| - "<java::array[reference]of_" |
| 336 | + "<array[reference]of_" |
334 | 337 | "java::java.lang.Float>";
|
335 | 338 | const irep_idt specialised_class_name = id2string(harness_class) + "$" +
|
336 | 339 | id2string(inner_class) +
|
@@ -389,3 +392,32 @@ SCENARIO(
|
389 | 392 | }
|
390 | 393 | }
|
391 | 394 | }
|
| 395 | + |
| 396 | +SCENARIO( |
| 397 | + "Test pretty printing auxiliary function", |
| 398 | + "[core][java_bytecode][generate_java_generic_type]") |
| 399 | +{ |
| 400 | + using std::map; |
| 401 | + using std::string; |
| 402 | + |
| 403 | + WHEN("We have a series of cbmc internal java types") |
| 404 | + { |
| 405 | + // NOLINTNEXTLINE |
| 406 | + const map<string, string> types{ |
| 407 | + // map<Input, Output> |
| 408 | + {"java::java.lang.Integer", "Integer"}, |
| 409 | + {"java::CustomClass", "CustomClass"}, |
| 410 | + {"java.lang.String", "String"}, |
| 411 | + {"Hashmap", "Hashmap"}, |
| 412 | + // We shouldn't prune types not imported in default import |
| 413 | + {"java.util.HashSet", "java.util.HashSet"}}; |
| 414 | + |
| 415 | + THEN("We need to make sure that the types get pruned correctly.") |
| 416 | + { |
| 417 | + for(const auto &pair : types) |
| 418 | + { |
| 419 | + REQUIRE(pretty_print_java_type(pair.first) == pair.second); |
| 420 | + } |
| 421 | + } |
| 422 | + } |
| 423 | +} |
0 commit comments