From c9eacb181cc2fe4c05e69a3231eae728cd232bfa Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 9 Nov 2015 23:54:09 +0300 Subject: [PATCH] Added tests --- Zend/tests/try/try_finally_019.phpt | 40 ++++++++++++++++++++++++++ Zend/tests/try/try_finally_020.phpt | 44 +++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 Zend/tests/try/try_finally_019.phpt create mode 100644 Zend/tests/try/try_finally_020.phpt diff --git a/Zend/tests/try/try_finally_019.phpt b/Zend/tests/try/try_finally_019.phpt new file mode 100644 index 0000000000..2e2069d1be --- /dev/null +++ b/Zend/tests/try/try_finally_019.phpt @@ -0,0 +1,40 @@ +--TEST-- +Combination of foreach, finally and goto (call order) +--FILE-- +n = $n; + } + function __destruct() { + echo "destruct" . $this->n . "\n"; + } +} + +foreach ([new A(1)] as $a) { + $a = null; + try { + foreach ([new A(2)] as $a) { + $a = null; + try { + foreach ([new A(3)] as $a) { + $a = null; + goto out; + } + } finally { + echo "finally1\n"; + } +out: ; + } + } finally { + echo "finally2\n"; + } +} +?> +--EXPECT-- +destruct3 +finally1 +destruct2 +finally2 +destruct1 diff --git a/Zend/tests/try/try_finally_020.phpt b/Zend/tests/try/try_finally_020.phpt new file mode 100644 index 0000000000..17756812fe --- /dev/null +++ b/Zend/tests/try/try_finally_020.phpt @@ -0,0 +1,44 @@ +--TEST-- +Combination of foreach, finally and exception (call order) +--XFAIL-- +See Bug #62210 and attempt to fix it in "tmp_liveliness" branch +--FILE-- +n = $n; + } + function __destruct() { + echo "destruct" . $this->n . "\n"; + } +} + +foreach ([new A(1)] as $a) { + $a = null; + try { + foreach ([new A(2)] as $a) { + $a = null; + try { + foreach ([new A(3)] as $a) { + $a = null; + throw new Exception(); + } + } finally { + echo "finally1\n"; + } + } + } catch (Exception $e) { + echo "catch\n"; + } finally { + echo "finally2\n"; + } +} +?> +--EXPECT-- +destruct3 +finally1 +destruct2 +catch +finally2 +destruct1 -- 2.50.1