Skip to content

Commit 20f8791

Browse files
Added more regression tests for runtime exceptions
1 parent 18714d5 commit 20f8791

File tree

18 files changed

+108
-21
lines changed

18 files changed

+108
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
public class ArrayIndexOutOfBoundsExceptionTest {
22
public static void main(String args[]) {
3-
try {
4-
int[] a=new int[4];
5-
a[6]=0;
6-
// TODO: fix the bytecode convertion such that there is no need for
7-
// an explicit throw in order to convert the handler
8-
throw new RuntimeException();
9-
}
10-
catch(ArrayIndexOutOfBoundsException exc) {
11-
assert false;
12-
}
3+
try {
4+
int[] a=new int[4];
5+
a[6]=0;
6+
// TODO: fix the bytecode convertion such that there is no need for
7+
// an explicit throw in order to convert the handler
8+
throw new RuntimeException();
9+
}
10+
catch(ArrayIndexOutOfBoundsException exc) {
11+
assert false;
12+
}
1313
}
1414
}
265 Bytes
Binary file not shown.
265 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class A {
2+
int i;
3+
}
4+
5+
class B {
6+
int j;
7+
}
8+
9+
public class ClassCastExceptionTest {
10+
public static void main(String args[]) {
11+
try {
12+
Object x = new Integer(0);
13+
String y=(String)x;
14+
throw new RuntimeException();
15+
}
16+
catch (ClassCastException exc) {
17+
assert false;
18+
}
19+
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
ClassCastExceptionTest.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file ClassCastExceptionTest.java line 17 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
265 Bytes
Binary file not shown.
265 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class A {
2+
int i;
3+
}
4+
5+
class B {
6+
int j;
7+
}
8+
9+
public class ClassCastExceptionTest {
10+
public static void main(String args[]) {
11+
try {
12+
Object x = new Integer(0);
13+
String y=(String)x;
14+
throw new RuntimeException();
15+
}
16+
catch (ClassCastException exc) {
17+
assert false;
18+
}
19+
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
ClassCastExceptionTest.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*Dynamic cast check: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
public class NegativeArraySizeExceptionTest {
22
public static void main(String args[]) {
33
try {
4-
int a[]=new int[-1];
5-
throw new RuntimeException();
4+
int a[]=new int[-1];
5+
throw new RuntimeException();
66
}
77
catch (NegativeArraySizeException exc) {
8-
assert false;
8+
assert false;
99
}
1010
}
1111
}

regression/cbmc-java/NullPointerException2/Test.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ class A {
66

77
public class Test {
88
public static void main(String args[]) {
9-
A a=null;
10-
try {
11-
int i=a.i;
12-
throw new B();
13-
}
14-
catch (NullPointerException exc) {
15-
assert false;
16-
}
9+
A a=null;
10+
try {
11+
int i=a.i;
12+
throw new B();
13+
}
14+
catch (NullPointerException exc) {
15+
assert false;
16+
}
1717
}
1818
}
247 Bytes
Binary file not shown.
241 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class B extends RuntimeException {}
2+
3+
class A {
4+
int i;
5+
}
6+
7+
public class Test {
8+
public static void main(String args[]) {
9+
A a=null;
10+
try {
11+
int i=a.i;
12+
throw new B();
13+
}
14+
catch (NullPointerException exc) {
15+
assert false;
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*reference is null in \*a: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring

0 commit comments

Comments
 (0)