Skip to content

Commit 655248a

Browse files
Add unit test for when there are no exceptions.
1 parent a6e7c4b commit 655248a

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed
Binary file not shown.
Binary file not shown.

jbmc/unit/java_bytecode/java_bytecode_parser/ThrowsExceptions.java

+4
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

+11-18
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,6 @@ 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 =
@@ -626,23 +624,18 @@ SCENARIO(
626624
irept("java.io.IOException").id()) != exceptions.end());
627625
}
628626
}
629-
}
630-
631-
const symbol_tablet &new_symbol_table2 = load_java_class(
632-
"ThrowsExceptions", "./java_bytecode/java_bytecode_parser");
633-
WHEN(
634-
"Parsing the exceptions attribute for a method that throws no exceptions")
635-
{
636-
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")
637629
{
638-
const symbolt &class_symbol =
639-
new_symbol_table2.lookup_ref("java::ThrowsExceptions");
640-
const symbolt &method_symbol =
641-
new_symbol_table2.lookup_ref("java::ThrowsExceptions.test:()V");
642-
const java_method_typet method = to_java_method_type(method_symbol.type);
643-
const std::vector<irept> exceptions = method.throws_exceptions();
644-
REQUIRE(exceptions.size() == 0);
645-
}
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+
}
646639
}
647640
}
648641
}

0 commit comments

Comments
 (0)