15
15
#include < util/language.h>
16
16
#include < util/message.h>
17
17
#include < java_bytecode/java_bytecode_language.h>
18
+ #include < src/java_bytecode/load_java_class.h>
18
19
19
20
SCENARIO (" java_bytecode_convert_abstract_class" ,
20
21
" [core][java_bytecode][java_bytecode_convert_class]" )
21
22
{
22
- std::unique_ptr<languaget>java_lang (new_java_bytecode_language ());
23
-
24
- // Configure the path loading
25
- cmdlinet command_line;
26
- command_line.set (
27
- " java-cp-include-files" ,
28
- " ./java_bytecode/java_bytecode_convert_class" );
29
- config.java .classpath .push_back (
30
- " ./java_bytecode/java_bytecode_convert_class" );
31
-
32
- // Configure the language
33
- null_message_handlert message_handler;
34
- java_lang->get_language_options (command_line);
35
- java_lang->set_message_handler (message_handler);
36
-
37
- std::istringstream java_code_stream (" ignored" );
38
-
39
23
GIVEN (" Some class files in the class path" )
40
24
{
41
25
WHEN (" Parsing an interface" )
42
26
{
43
- java_lang->parse (java_code_stream, " I.class" );
44
-
45
- symbol_tablet new_symbol_table;
46
- java_lang->typecheck (new_symbol_table, " " );
27
+ const symbol_tablet &new_symbol_table=
28
+ load_java_class (" I" , " ./java_bytecode/java_bytecode_convert_class" );
47
29
48
- java_lang->final (new_symbol_table);
49
-
50
- REQUIRE (new_symbol_table.has_symbol (" java::I" ));
51
30
THEN (" The symbol type should be abstract" )
52
31
{
53
32
const symbolt &class_symbol=new_symbol_table.lookup (" java::I" );
@@ -61,14 +40,8 @@ SCENARIO("java_bytecode_convert_abstract_class",
61
40
}
62
41
WHEN (" Parsing an abstract class" )
63
42
{
64
- java_lang->parse (java_code_stream, " A.class" );
65
-
66
- symbol_tablet new_symbol_table;
67
- java_lang->typecheck (new_symbol_table, " " );
68
-
69
- java_lang->final (new_symbol_table);
70
-
71
- REQUIRE (new_symbol_table.has_symbol (" java::A" ));
43
+ const symbol_tablet &new_symbol_table=
44
+ load_java_class (" A" , " ./java_bytecode/java_bytecode_convert_class" );
72
45
THEN (" The symbol type should be abstract" )
73
46
{
74
47
const symbolt &class_symbol=new_symbol_table.lookup (" java::A" );
@@ -82,14 +55,8 @@ SCENARIO("java_bytecode_convert_abstract_class",
82
55
}
83
56
WHEN (" Passing a concrete class" )
84
57
{
85
- java_lang->parse (java_code_stream, " C.class" );
86
-
87
- symbol_tablet new_symbol_table;
88
- java_lang->typecheck (new_symbol_table, " " );
89
-
90
- java_lang->final (new_symbol_table);
91
-
92
- REQUIRE (new_symbol_table.has_symbol (" java::C" ));
58
+ const symbol_tablet &new_symbol_table=
59
+ load_java_class (" C" , " ./java_bytecode/java_bytecode_convert_class" );
93
60
THEN (" The symbol type should not be abstract" )
94
61
{
95
62
const symbolt &class_symbol=new_symbol_table.lookup (" java::C" );
@@ -103,14 +70,10 @@ SCENARIO("java_bytecode_convert_abstract_class",
103
70
}
104
71
WHEN (" Passing a concrete class that implements an interface" )
105
72
{
106
- java_lang->parse (java_code_stream, " Implementor.class" );
107
-
108
- symbol_tablet new_symbol_table;
109
- java_lang->typecheck (new_symbol_table, " " );
110
-
111
- java_lang->final (new_symbol_table);
112
-
113
- REQUIRE (new_symbol_table.has_symbol (" java::Implementor" ));
73
+ const symbol_tablet &new_symbol_table=
74
+ load_java_class (
75
+ " Implementor" ,
76
+ " ./java_bytecode/java_bytecode_convert_class" );
114
77
THEN (" The symbol type should not be abstract" )
115
78
{
116
79
const symbolt &class_symbol=
@@ -125,18 +88,14 @@ SCENARIO("java_bytecode_convert_abstract_class",
125
88
}
126
89
WHEN (" Passing a concrete class that extends an abstract class" )
127
90
{
128
- java_lang->parse (java_code_stream, " Extendor.class" );
129
-
130
- symbol_tablet new_symbol_table;
131
- java_lang->typecheck (new_symbol_table, " " );
132
-
133
- java_lang->final (new_symbol_table);
134
-
135
- REQUIRE (new_symbol_table.has_symbol (" java::Extendor" ));
91
+ const symbol_tablet &new_symbol_table=
92
+ load_java_class (
93
+ " Extender" ,
94
+ " ./java_bytecode/java_bytecode_convert_class" );
136
95
THEN (" The symbol type should not be abstract" )
137
96
{
138
97
const symbolt &class_symbol=
139
- new_symbol_table.lookup (" java::Extendor " );
98
+ new_symbol_table.lookup (" java::Extender " );
140
99
const typet &symbol_type=class_symbol.type ;
141
100
142
101
REQUIRE (symbol_type.id ()==ID_struct);
0 commit comments