Skip to content

Commit 08ea814

Browse files
fixup! Update unit tests and add one with no exceptions
1 parent 055d30f commit 08ea814

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

jbmc/unit/java_bytecode/java_bytecode_parser/ThrowsExceptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ public static void test() throws CustomException, IOException {
88
throw new CustomException();
99
}
1010

11+
public static void testNoExceptions() {
12+
StringReader sr = new StringReader("");
13+
}
14+
1115
}
1216

1317
class CustomException extends Exception {

jbmc/unit/java_bytecode/java_bytecode_parser/parse_java_attributes.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -606,42 +606,36 @@ SCENARIO(
606606
{
607607
THEN("We should be able to get the list of exceptions it throws")
608608
{
609-
const symbolt &class_symbol =
610-
new_symbol_table.lookup_ref("java::ThrowsExceptions");
611609
const symbolt &method_symbol =
612610
new_symbol_table.lookup_ref("java::ThrowsExceptions.test:()V");
613611
const java_method_typet method =
614612
to_java_method_type(method_symbol.type);
615-
const std::vector<irept> exceptions = method.throws_exceptions();
613+
const std::vector<irep_idt> exceptions = method.throws_exceptions();
616614
REQUIRE(exceptions.size() == 2);
617615
REQUIRE(
618616
std::find(
619-
exceptions.begin(), exceptions.end(), irept("CustomException")) !=
620-
exceptions.end());
617+
exceptions.begin(),
618+
exceptions.end(),
619+
irept("CustomException").id()) != exceptions.end());
621620
REQUIRE(
622621
std::find(
623622
exceptions.begin(),
624623
exceptions.end(),
625-
irept("java.io.IOException")) != exceptions.end());
624+
irept("java.io.IOException").id()) != exceptions.end());
626625
}
627626
}
628-
}
629-
630-
const symbol_tablet &new_symbol_table2 = load_java_class(
631-
"ThrowsExceptions", "./java_bytecode/java_bytecode_parser");
632-
WHEN(
633-
"Parsing the exceptions attribute for a method that throws no exceptions")
634-
{
635-
THEN("We should be able to get the list of exceptions it throws")
627+
WHEN(
628+
"Parsing the exceptions attribute for a method that throws no exceptions")
636629
{
637-
const symbolt &class_symbol =
638-
new_symbol_table2.lookup_ref("java::ThrowsExceptions");
639-
const symbolt &method_symbol =
640-
new_symbol_table2.lookup_ref("java::ThrowsExceptions.test:()V");
641-
const java_method_typet method = to_java_method_type(method_symbol.type);
642-
const std::vector<irept> exceptions = method.throws_exceptions();
643-
REQUIRE(exceptions.size() == 0);
644-
}
630+
THEN("We should be able to get the list of exceptions it throws")
631+
{
632+
const symbolt &method_symbol = new_symbol_table.lookup_ref(
633+
"java::ThrowsExceptions.testNoExceptions:()V");
634+
const java_method_typet method =
635+
to_java_method_type(method_symbol.type);
636+
const std::vector<irep_idt> exceptions = method.throws_exceptions();
637+
REQUIRE(exceptions.size() == 0);
638+
}
645639
}
646640
}
647641
}

0 commit comments

Comments
 (0)