Skip to content

Commit 28fbcce

Browse files
committed
Rerun inner class unit test with outer and inner loaded first
1 parent 61e4d58 commit 28fbcce

File tree

1 file changed

+82
-76
lines changed

1 file changed

+82
-76
lines changed

jbmc/unit/java_bytecode/java_bytecode_parser/parse_inner_class.cpp

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,97 +10,103 @@
1010
#include <java_bytecode/java_types.h>
1111
#include <testing-utils/catch.hpp>
1212

13+
#include <string>
14+
#include <vector>
15+
1316
SCENARIO(
1417
"Parsing inner java classes",
1518
"[core][java_bytecode][java_bytecode_parser]")
1619
{
17-
GIVEN("A class file of an inner class.")
20+
for(const auto &load_first : std::vector<std::string>{"Outer$Inner", "Outer"})
1821
{
19-
WHEN("Parsing an inner class called \"Inner\".")
20-
{
21-
const symbol_tablet &symbol_table = load_java_class(
22-
"Outer$Inner", "./java_bytecode/java_bytecode_parser");
23-
const symbolt *class_symbol = symbol_table.lookup("java::Outer$Inner");
24-
REQUIRE(class_symbol);
25-
const java_class_typet *class_type =
26-
type_try_dynamic_cast<java_class_typet>(class_symbol->type);
27-
REQUIRE(class_type);
22+
const symbol_tablet &symbol_table =
23+
load_java_class(load_first, "./java_bytecode/java_bytecode_parser");
2824

29-
THEN("The inner class should have the name \"java::Outer$Inner\".")
30-
{
31-
REQUIRE(id2string(class_type->get_name()) == "java::Outer$Inner");
32-
}
33-
THEN("The inner class should have the inner name \"Inner\".")
34-
{
35-
REQUIRE(id2string(class_type->get_inner_name()) == "Inner");
36-
}
37-
THEN("The inner class is not considered to be an anonymous class.")
38-
{
39-
REQUIRE_FALSE(class_type->get_is_anonymous_class());
40-
}
41-
THEN("The inner class has the outer class \"Outer\".")
25+
GIVEN("A class file of an inner class and " + load_first + " loaded first.")
26+
{
27+
WHEN("Parsing an inner class called \"Inner\".")
4228
{
43-
REQUIRE(id2string(class_type->get_outer_class()) == "Outer");
29+
const symbolt *class_symbol = symbol_table.lookup("java::Outer$Inner");
30+
REQUIRE(class_symbol);
31+
const java_class_typet *class_type =
32+
type_try_dynamic_cast<java_class_typet>(class_symbol->type);
33+
REQUIRE(class_type);
34+
35+
THEN("The inner class should have the name \"java::Outer$Inner\".")
36+
{
37+
REQUIRE(id2string(class_type->get_name()) == "java::Outer$Inner");
38+
}
39+
THEN("The inner class should have the inner name \"Inner\".")
40+
{
41+
REQUIRE(id2string(class_type->get_inner_name()) == "Inner");
42+
}
43+
THEN("The inner class is not considered to be an anonymous class.")
44+
{
45+
REQUIRE_FALSE(class_type->get_is_anonymous_class());
46+
}
47+
THEN("The inner class has the outer class \"Outer\".")
48+
{
49+
REQUIRE(id2string(class_type->get_outer_class()) == "Outer");
50+
}
4451
}
4552
}
46-
}
47-
GIVEN("A class file of a class which is not an inner class.")
48-
{
49-
WHEN("Parsing an outer class.")
53+
GIVEN(
54+
"A class file of a class which is not an inner class and " + load_first +
55+
" loaded first.")
5056
{
51-
const symbol_tablet &symbol_table =
52-
load_java_class("Outer", "./java_bytecode/java_bytecode_parser");
53-
const symbolt *class_symbol = symbol_table.lookup("java::Outer");
54-
REQUIRE(class_symbol);
55-
const java_class_typet *class_type =
56-
type_try_dynamic_cast<java_class_typet>(class_symbol->type);
57-
REQUIRE(class_type);
58-
59-
THEN("The outer class should have the name \"java::Outer\".")
60-
{
61-
REQUIRE(id2string(class_type->get_name()) == "java::Outer");
62-
}
63-
THEN("The outer class should not have an inner name.")
57+
WHEN("Parsing an outer class.")
6458
{
65-
REQUIRE(id2string(class_type->get_inner_name()).empty());
66-
}
67-
THEN("The outer class is not considered to be an anonymous class.")
68-
{
69-
REQUIRE_FALSE(class_type->get_is_anonymous_class());
70-
}
71-
THEN("The outer class does not have an outer class.")
72-
{
73-
REQUIRE(id2string(class_type->get_outer_class()).empty());
59+
const symbolt *class_symbol = symbol_table.lookup("java::Outer");
60+
REQUIRE(class_symbol);
61+
const java_class_typet *class_type =
62+
type_try_dynamic_cast<java_class_typet>(class_symbol->type);
63+
REQUIRE(class_type);
64+
65+
THEN("The outer class should have the name \"java::Outer\".")
66+
{
67+
REQUIRE(id2string(class_type->get_name()) == "java::Outer");
68+
}
69+
THEN("The outer class should not have an inner name.")
70+
{
71+
REQUIRE(id2string(class_type->get_inner_name()).empty());
72+
}
73+
THEN("The outer class is not considered to be an anonymous class.")
74+
{
75+
REQUIRE_FALSE(class_type->get_is_anonymous_class());
76+
}
77+
THEN("The outer class does not have an outer class.")
78+
{
79+
REQUIRE(id2string(class_type->get_outer_class()).empty());
80+
}
7481
}
7582
}
76-
}
77-
GIVEN("A class file of an anonymous class.")
78-
{
79-
WHEN("Parsing an anonymous class.")
83+
GIVEN(
84+
"A class file of an anonymous class and " + load_first + " loaded first.")
8085
{
81-
const symbol_tablet &symbol_table = load_java_class(
82-
"Outer$1", "./java_bytecode/java_bytecode_parser");
83-
const symbolt *class_symbol = symbol_table.lookup("java::Outer$1");
84-
REQUIRE(class_symbol);
85-
const java_class_typet *class_type =
86-
type_try_dynamic_cast<java_class_typet>(class_symbol->type);
87-
REQUIRE(class_type);
88-
89-
THEN("The anonymous class should have the name \"java::Outer$1\".")
86+
WHEN("Parsing an anonymous class.")
9087
{
91-
REQUIRE(id2string(class_type->get_name()) == "java::Outer$1");
92-
}
93-
THEN("The anonymous class should not have an inner name.")
94-
{
95-
REQUIRE(id2string(class_type->get_inner_name()).empty());
96-
}
97-
THEN("The anonymous class is considered to be an anonymous class.")
98-
{
99-
REQUIRE(class_type->get_is_anonymous_class());
100-
}
101-
THEN("The anonymous class does not have an outer class.")
102-
{
103-
REQUIRE(id2string(class_type->get_outer_class()).empty());
88+
const symbolt *class_symbol = symbol_table.lookup("java::Outer$1");
89+
REQUIRE(class_symbol);
90+
const java_class_typet *class_type =
91+
type_try_dynamic_cast<java_class_typet>(class_symbol->type);
92+
REQUIRE(class_type);
93+
94+
THEN("The anonymous class should have the name \"java::Outer$1\".")
95+
{
96+
REQUIRE(id2string(class_type->get_name()) == "java::Outer$1");
97+
}
98+
THEN("The anonymous class should not have an inner name.")
99+
{
100+
REQUIRE(id2string(class_type->get_inner_name()).empty());
101+
}
102+
THEN("The anonymous class is considered to be an anonymous class.")
103+
{
104+
REQUIRE(class_type->get_is_anonymous_class());
105+
}
106+
THEN("The anonymous class does not have an outer class.")
107+
{
108+
REQUIRE(id2string(class_type->get_outer_class()).empty());
109+
}
104110
}
105111
}
106112
}

0 commit comments

Comments
 (0)