]> granicus.if.org Git - php/commitdiff
Added and fixed tests related to "finally" handling
authorDmitry Stogov <dmitry@zend.com>
Thu, 19 May 2016 10:22:46 +0000 (13:22 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 19 May 2016 10:22:46 +0000 (13:22 +0300)
Zend/tests/try/bug70228.phpt
Zend/tests/try/bug72213.phpt [new file with mode: 0644]
Zend/tests/try/bug72213_2.phpt [new file with mode: 0644]

index 23f58647408b7eb01de320250d3f6362797ca8a4..e85724765e6b902c318a893bee4d647378ab8726 100644 (file)
@@ -7,10 +7,10 @@ See https://bugs.php.net/bug.php?id=70228
 
 function foo() {
     try { return str_repeat("a", 2); }
-    finally { return true; }
+    finally { return str_repeat("b", 2); }
 }
 
 var_dump(foo());
 ?>
 --EXPECT--
-string(3) "bar"
+string(2) "bb"
diff --git a/Zend/tests/try/bug72213.phpt b/Zend/tests/try/bug72213.phpt
new file mode 100644 (file)
index 0000000..aee4c95
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #72213 (Finally leaks on nested exceptions)
+--XFAIL--
+See https://bugs.php.net/bug.php?id=72213
+--FILE--
+<?php
+function test() {
+       try {
+               throw new Exception('a');
+       } finally {
+               try {
+                       throw new Exception('b');
+               } finally {
+               }
+       }
+}
+
+try {
+       test();
+} catch (Exception $e) {
+       var_dump($e->getMessage());
+       var_dump($e->getPrevious()->getMessage());
+}
+?>
+--EXPECT--
+string(1) "b"
+string(1) "a"
diff --git a/Zend/tests/try/bug72213_2.phpt b/Zend/tests/try/bug72213_2.phpt
new file mode 100644 (file)
index 0000000..790abe1
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Bug #72213 (Finally leaks on nested exceptions)
+--FILE--
+<?php
+function test() {
+    try {
+        throw new Exception(1);
+    } finally {
+        try {
+            try {
+                throw new Exception(2);
+            } finally {
+            }
+        } catch (Exception $e) {
+        }
+    }
+}
+
+try {
+    test();
+} catch (Exception $e) {
+    echo "caught {$e->getMessage()}\n";
+}
+--EXPECT--
+caught 1