File tree 5 files changed +65
-0
lines changed
jbmc/regression/jbmc/assert-no-exceptions-thrown
5 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ class MyException extends Exception {}
2
+
3
+ public class Test {
4
+ public static int mayThrow (char branch ) throws Throwable {
5
+ if (branch == 'n' ) {
6
+ throw new NullPointerException ();
7
+ } else if (branch == 'c' ) {
8
+ throw new MyException ();
9
+ } else if (branch == 't' ) {
10
+ throw new Throwable ();
11
+ } else if (branch == 'r' ) {
12
+ return 2 ;
13
+ } else {
14
+ return 1 ;
15
+ }
16
+ }
17
+
18
+ public static void check (char branch ) {
19
+ try {
20
+ int i = mayThrow (branch );
21
+ if (i == 2 )
22
+ assert false ;
23
+ if (i == 1 )
24
+ assert false ;
25
+ } catch (MyException e ) {
26
+ assert false ;
27
+ } catch (NullPointerException e ) {
28
+ assert false ;
29
+ } catch (Throwable e ) {
30
+ assert false ;
31
+ }
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --function Test.check
4
+ line 22 assertion at file Test.java line 22 .*: FAILURE
5
+ line 24 assertion at file Test.java line 24 .*: FAILURE
6
+ line 26 assertion at file Test.java line 26 .*: FAILURE
7
+ line 28 assertion at file Test.java line 28 .*: FAILURE
8
+ line 30 assertion at file Test.java line 30 .*: FAILURE
9
+ ^EXIT=10$
10
+ ^SIGNAL=0$
11
+ --
12
+ --
13
+ Checks that we get the expected behaviour when --assert-no-exceptions-thrown is
14
+ not used. This is to make sure that test.desc is actually testing what we wanted.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --function Test.check --assert-no-exceptions-thrown
4
+ line 6 assertion at file Test.java line 6 .*: FAILURE
5
+ line 8 assertion at file Test.java line 8 .*: FAILURE
6
+ line 10 assertion at file Test.java line 10 .*: FAILURE
7
+ line 22 assertion at file Test.java line 22 .*: FAILURE
8
+ line 24 assertion at file Test.java line 24 .*: FAILURE
9
+ line 26 assertion at file Test.java line 26 .*: SUCCESS
10
+ line 28 assertion at file Test.java line 28 .*: SUCCESS
11
+ line 30 assertion at file Test.java line 30 .*: SUCCESS
12
+ ^EXIT=10$
13
+ ^SIGNAL=0$
14
+ --
15
+ --
16
+ Checks that the `throw` instructions have been replaced by assertions, which
17
+ are failing here because they are reachable, and assumptions which prevent
18
+ the last three assertions from failing.
You can’t perform that action at this time.
0 commit comments