Skip to content

Commit d15c67d

Browse files
committed
Add tests for Java finally construct
These check that a finally block is accessible when a catch block is absent, present and catches, present and does not catch, and present without any exception being thrown at all. The first three cases are then repeated for the case where an exception escapes from a function rather than being thrown locally.
1 parent 08f6b27 commit d15c67d

File tree

21 files changed

+166
-0
lines changed

21 files changed

+166
-0
lines changed
594 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
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+
assertion at file test\.java line 7 function java::test\.main:\(\)V bytecode-index 9: FAILURE
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
throw new Exception();
5+
}
6+
finally {
7+
assert(false);
8+
}
9+
}
10+
}
11+
637 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
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+
assertion at file test\.java line 8 function java::test\.main:\(\)V bytecode-index 9: FAILURE
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
throw new Exception();
5+
}
6+
catch(Exception e) { }
7+
finally {
8+
assert(false);
9+
}
10+
}
11+
}
12+
727 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file test\.java line 7 function java::test\.main:\(\)V bytecode-index 9: SUCCESS
7+
assertion at file test\.java line 10 function java::test\.main:\(\)V bytecode-index 22: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
throw new NullPointerException();
5+
}
6+
catch(ArithmeticException e) {
7+
assert(false);
8+
}
9+
finally {
10+
assert(false);
11+
}
12+
}
13+
}
14+
713 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
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+
assertion at file test\.java line 11 function java::test\.main:\(\)V bytecode-index 7: FAILURE
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
int x = 1;
5+
x++;
6+
}
7+
catch(ArithmeticException e) {
8+
assert(false);
9+
}
10+
finally {
11+
assert(false);
12+
}
13+
}
14+
}
15+
681 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
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+
assertion at file test\.java line 7 function java::test\.main:\(\)V bytecode-index 12: FAILURE
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
f();
5+
}
6+
finally {
7+
assert(false);
8+
}
9+
}
10+
11+
public static void f() throws Exception {
12+
throw new Exception();
13+
}
14+
}
15+
720 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
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+
assertion at file test\.java line 8 function java::test\.main:\(\)V bytecode-index 12: FAILURE
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
f();
5+
}
6+
catch(Exception e) { }
7+
finally {
8+
assert(false);
9+
}
10+
}
11+
12+
public static void f() throws Exception {
13+
throw new Exception();
14+
}
15+
}
16+
818 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
assertion at file test\.java line 7 function java::test\.main:\(\)V bytecode-index 12: SUCCESS
7+
assertion at file test\.java line 10 function java::test\.main:\(\)V bytecode-index 25: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class test {
2+
public static void main() throws Exception {
3+
try {
4+
f();
5+
}
6+
catch(ArithmeticException e) {
7+
assert(false);
8+
}
9+
finally {
10+
assert(false);
11+
}
12+
}
13+
14+
public static void f() throws NullPointerException {
15+
throw new NullPointerException();
16+
}
17+
}
18+

0 commit comments

Comments
 (0)