Skip to content

Commit c9eacb1

Browse files
committed
Added tests
1 parent e029a86 commit c9eacb1

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

Zend/tests/try/try_finally_019.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Combination of foreach, finally and goto (call order)
3+
--FILE--
4+
<?php
5+
class A {
6+
public $n = 0;
7+
function __construct($n) {
8+
$this->n = $n;
9+
}
10+
function __destruct() {
11+
echo "destruct" . $this->n . "\n";
12+
}
13+
}
14+
15+
foreach ([new A(1)] as $a) {
16+
$a = null;
17+
try {
18+
foreach ([new A(2)] as $a) {
19+
$a = null;
20+
try {
21+
foreach ([new A(3)] as $a) {
22+
$a = null;
23+
goto out;
24+
}
25+
} finally {
26+
echo "finally1\n";
27+
}
28+
out: ;
29+
}
30+
} finally {
31+
echo "finally2\n";
32+
}
33+
}
34+
?>
35+
--EXPECT--
36+
destruct3
37+
finally1
38+
destruct2
39+
finally2
40+
destruct1

Zend/tests/try/try_finally_020.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
Combination of foreach, finally and exception (call order)
3+
--XFAIL--
4+
See Bug #62210 and attempt to fix it in "tmp_liveliness" branch
5+
--FILE--
6+
<?php
7+
class A {
8+
public $n = 0;
9+
function __construct($n) {
10+
$this->n = $n;
11+
}
12+
function __destruct() {
13+
echo "destruct" . $this->n . "\n";
14+
}
15+
}
16+
17+
foreach ([new A(1)] as $a) {
18+
$a = null;
19+
try {
20+
foreach ([new A(2)] as $a) {
21+
$a = null;
22+
try {
23+
foreach ([new A(3)] as $a) {
24+
$a = null;
25+
throw new Exception();
26+
}
27+
} finally {
28+
echo "finally1\n";
29+
}
30+
}
31+
} catch (Exception $e) {
32+
echo "catch\n";
33+
} finally {
34+
echo "finally2\n";
35+
}
36+
}
37+
?>
38+
--EXPECT--
39+
destruct3
40+
finally1
41+
destruct2
42+
catch
43+
finally2
44+
destruct1

0 commit comments

Comments
 (0)