File tree 5 files changed +68
-0
lines changed
jbmc/regression/jbmc/assume-no-exceptions-thrown 5 files changed +68
-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 (String branch ) throws Throwable {
5
+ if (branch == null ) {
6
+ return -1 ;
7
+ }
8
+ if (branch .startsWith ("null pointer exception" )) {
9
+ throw new NullPointerException ();
10
+ } else if (branch .startsWith ("custom exception" )) {
11
+ throw new MyException ();
12
+ } else if (branch .startsWith ("throwable" )) {
13
+ throw new Throwable ();
14
+ } else if (branch .startsWith ("return 2" )) {
15
+ return 2 ;
16
+ } else {
17
+ return 1 ;
18
+ }
19
+ }
20
+
21
+ public static void check (String branch ) {
22
+ try {
23
+ int i = mayThrow (branch );
24
+ if (i == 2 )
25
+ assert false ;
26
+ if (i == 1 )
27
+ assert false ;
28
+ } catch (MyException e ) {
29
+ assert false ;
30
+ } catch (NullPointerException e ) {
31
+ assert false ;
32
+ } catch (Throwable e ) {
33
+ assert false ;
34
+ }
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --function Test.check
4
+ line 26 assertion at file Test.java line 26 .*: FAILURE
5
+ line 28 assertion at file Test.java line 28 .*: FAILURE
6
+ line 30 assertion at file Test.java line 30 .*: FAILURE
7
+ line 32 assertion at file Test.java line 32 .*: FAILURE
8
+ line 34 assertion at file Test.java line 34 .*: FAILURE
9
+ ^EXIT=10$
10
+ ^SIGNAL=0$
11
+ --
12
+ --
13
+ Checks that we get the expected behaviour when --assume-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 --assume-no-exceptions-thrown
4
+ line 10 assertion at file Test.java line 10 .*: FAILURE
5
+ line 12 assertion at file Test.java line 12 .*: FAILURE
6
+ line 14 assertion at file Test.java line 14 .*: FAILURE
7
+ line 26 assertion at file Test.java line 26 .*: FAILURE
8
+ line 28 assertion at file Test.java line 28 .*: FAILURE
9
+ line 30 assertion at file Test.java line 30 .*: SUCCESS
10
+ line 32 assertion at file Test.java line 32 .*: SUCCESS
11
+ line 34 assertion at file Test.java line 34 .*: 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