File tree 3 files changed +68
-0
lines changed
jbmc/regression/jbmc/assert-no-exceptions-thrown
3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Thrower {
2
+ public static void test (Integer t ) {
3
+ String ret = "" ;
4
+ if (t != null )
5
+ try {
6
+ switch (t ) {
7
+ case 1 :
8
+ ret = "CCE" ;
9
+ Object o = new Integer (0 );
10
+ String x = ((String ) o );
11
+ break ;
12
+
13
+ case 2 :
14
+ ret = "AIOBE" ;
15
+ int [] xs = new int [3 ];
16
+ t = xs [5 ];
17
+
18
+ case 3 :
19
+ ret = "AE" ;
20
+ t = 5 / 0 ;
21
+
22
+ case 4 :
23
+ ret = "NASE" ;
24
+ Integer [] arr = new Integer [-7 ];
25
+
26
+ case 5 :
27
+ ret = "NPE" ;
28
+ String str = null ;
29
+ str .toLowerCase ();
30
+
31
+ default :
32
+ break ;
33
+ }
34
+ } catch (ClassCastException | NegativeArraySizeException
35
+ | NullPointerException | ArithmeticException
36
+ | ArrayIndexOutOfBoundsException e3 ) {
37
+
38
+ if (e3 instanceof ClassCastException )
39
+ assert ret .equals ("CCE" );
40
+
41
+ if (e3 instanceof NegativeArraySizeException )
42
+ assert ret .equals ("NASE" );
43
+
44
+ if (e3 instanceof NullPointerException )
45
+ assert ret .equals ("NPE" );
46
+
47
+ if (e3 instanceof ArithmeticException )
48
+ assert ret .equals ("AE" );
49
+
50
+ if (e3 instanceof ArrayIndexOutOfBoundsException )
51
+ assert ret .equals ("AIOBE" );
52
+ }
53
+ }
54
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Thrower.class
3
+ --function Thrower.test --assert-no-exceptions-thrown --throw-runtime-exceptions
4
+ line 39 assertion at file Thrower.java line 39 .*: FAILURE
5
+ line 42 assertion at file Thrower.java line 42 .*: FAILURE
6
+ line 45 assertion at file Thrower.java line 45 .*: FAILURE
7
+ line 48 assertion at file Thrower.java line 48 .*: FAILURE
8
+ line 51 assertion at file Thrower.java line 51 .*: FAILURE
9
+ ^EXIT=10$
10
+ ^SIGNAL=0$
11
+ --
12
+ --
13
+ Checks that the runtime exceptions still throw with `--throw-runtime-exceptions`
14
+ even when `--assert-no-exceptions-thrown` is specified.
You can’t perform that action at this time.
0 commit comments