Skip to content

Commit 72677f2

Browse files
Add regression test for runtime exceptions instrumentation
1 parent b63547f commit 72677f2

24 files changed

+130
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class ArrayIndexOutOfBoundsExceptionTest {
2+
public static void main(String args[]) {
3+
try {
4+
int[] a=new int[4];
5+
a[4]=0;
6+
throw new RuntimeException();
7+
}
8+
catch (ArrayIndexOutOfBoundsException exc) {
9+
assert false;
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
ArrayIndexOutOfBoundsExceptionTest.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file ArrayIndexOutOfBoundsExceptionTest.java line 9 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,13 @@
1+
public class ClassCastExceptionTest {
2+
public static void main(String args[]) {
3+
try {
4+
Object x = new Integer(0);
5+
String y = (String)x;
6+
throw new RuntimeException();
7+
}
8+
catch (ClassCastException exc) {
9+
assert false;
10+
}
11+
12+
}
13+
}
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 9 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
249 Bytes
Binary file not shown.
234 Bytes
Binary file not shown.
234 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+
3+
class B extends A {}
4+
5+
class C extends B {}
6+
7+
public class ClassCastExceptionTest {
8+
public static void main(String args[]) {
9+
try {
10+
A c = new C();
11+
B b = (B)c;
12+
// TODO: an explicit throw is currently needed in order
13+
// for CBMC to convert the exception handler
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,8 @@
1+
CORE
2+
ClassCastExceptionTest.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
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,20 @@
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+
a.i=0;
12+
// TODO: an explicit throw is currently needed in order
13+
// for CBMC to convert the exception handler
14+
throw new B();
15+
}
16+
catch (NullPointerException exc) {
17+
assert false;
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file Test.java line 15 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
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,20 @@
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+
// TODO: an explicit throw is currently needed in order
13+
// for CBMC to convert the exception handler
14+
throw new B();
15+
}
16+
catch (NullPointerException exc) {
17+
assert false;
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
Test.class
3+
--java-throw-runtime-exceptions
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^.*assertion at file Test.java line 15 function.*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring

0 commit comments

Comments
 (0)