|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | + Module: Unit tests for parsing generic classes |
| 4 | +
|
| 5 | + Author: DiffBlue Limited. All rights reserved. |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include <catch.hpp> |
| 10 | + |
| 11 | +#include <util/config.h> |
| 12 | +#include <util/cmdline.h> |
| 13 | +#include <util/language.h> |
| 14 | +#include <util/prefix.h> |
| 15 | + |
| 16 | +#include <java_bytecode/java_bytecode_language.h> |
| 17 | + |
| 18 | +#include <iostream> |
| 19 | + |
| 20 | +SCENARIO( |
| 21 | + "java_bytecode_parse_generic_wildcard", |
| 22 | + "[core][java_bytecode][java_bytecode_parse_generics]") |
| 23 | +{ |
| 24 | + std::unique_ptr<languaget>java_lang(new_java_bytecode_language()); |
| 25 | + |
| 26 | + // Configure the path loading |
| 27 | + cmdlinet command_line; |
| 28 | + command_line.set( |
| 29 | + "java-cp-include-files", |
| 30 | + "./java_bytecode/java_bytecode_parse_generics"); |
| 31 | + config.java.classpath.push_back( |
| 32 | + "./java_bytecode/java_bytecode_parse_generics"); |
| 33 | + |
| 34 | + std::istringstream java_code_stream("ignored"); |
| 35 | + null_message_handlert message_handler; |
| 36 | + |
| 37 | + java_lang->get_language_options(command_line); |
| 38 | + java_lang->set_message_handler(message_handler); |
| 39 | + java_lang->parse(java_code_stream, "WildcardGenericFunctions.class"); |
| 40 | + symbol_tablet new_symbol_table; |
| 41 | + java_lang->typecheck(new_symbol_table, ""); |
| 42 | + java_lang->final(new_symbol_table); |
| 43 | + |
| 44 | + std::string class_prefix="java::WildcardGenericFunctions"; |
| 45 | + |
| 46 | + // Validate loaded the java file |
| 47 | + REQUIRE(new_symbol_table.has_symbol(class_prefix)); |
| 48 | + |
| 49 | + THEN("There should be a symbol for processSimpleGeneric") |
| 50 | + { |
| 51 | + const std::string func_name=".processSimpleGeneric"; |
| 52 | + const std::string func_descriptor=":(LSimpleGeneric;)V"; |
| 53 | + const std::string process_func_name=class_prefix+func_name+func_descriptor; |
| 54 | + |
| 55 | + REQUIRE(new_symbol_table.has_symbol(process_func_name)); |
| 56 | + } |
| 57 | + |
| 58 | + THEN("There should be a symbol for processUpperBoundInterfaceGeneric") |
| 59 | + { |
| 60 | + const std::string func_name=".processUpperBoundInterfaceGeneric"; |
| 61 | + const std::string func_descriptor=":(LSimpleGeneric;)V"; |
| 62 | + const std::string process_func_name=class_prefix+func_name+func_descriptor; |
| 63 | + |
| 64 | + REQUIRE(new_symbol_table.has_symbol(process_func_name)); |
| 65 | + } |
| 66 | + |
| 67 | + THEN("There should be a symbol for processUpperBoundClassGeneric") |
| 68 | + { |
| 69 | + const std::string func_name=".processUpperBoundClassGeneric"; |
| 70 | + const std::string func_descriptor=":(LSimpleGeneric;)V"; |
| 71 | + const std::string process_func_name=class_prefix+func_name+func_descriptor; |
| 72 | + |
| 73 | + REQUIRE(new_symbol_table.has_symbol(process_func_name)); |
| 74 | + } |
| 75 | + |
| 76 | + THEN("There should be a symbol for processLowerBoundGeneric") |
| 77 | + { |
| 78 | + const std::string func_name=".processLowerBoundGeneric"; |
| 79 | + const std::string func_descriptor=":(LSimpleGeneric;LFoo;)V"; |
| 80 | + const std::string process_func_name=class_prefix+func_name+func_descriptor; |
| 81 | + |
| 82 | + REQUIRE(new_symbol_table.has_symbol(process_func_name)); |
| 83 | + } |
| 84 | +} |
0 commit comments