]> granicus.if.org Git - php/commitdiff
improve test coverage of multicatch
authorJoe Watkins <krakjoe@php.net>
Mon, 2 May 2016 17:48:50 +0000 (18:48 +0100)
committerJoe Watkins <krakjoe@php.net>
Mon, 2 May 2016 17:48:50 +0000 (18:48 +0100)
Zend/tests/try/exceptions.inc
Zend/tests/try/try_multicatch_006.phpt [new file with mode: 0644]
Zend/tests/try/try_multicatch_007.phpt [new file with mode: 0644]

index 8a8777914c976723033801e0fe09e4272d2e3e1e..68cb1c62f70e1ed4d2337898c05818e8074be191 100644 (file)
@@ -3,3 +3,4 @@
 class Exception1 extends Exception {}
 class Exception2 extends Exception {}
 class Exception3 extends Exception {}
+class Exception4 extends Exception {}
diff --git a/Zend/tests/try/try_multicatch_006.phpt b/Zend/tests/try/try_multicatch_006.phpt
new file mode 100644 (file)
index 0000000..e4505f1
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Catch first exception in the second multicatch
+--FILE--
+<?php
+require_once __DIR__ . '/exceptions.inc';
+
+try {
+       echo 'TRY' . PHP_EOL;
+       throw new Exception3;
+} catch(Exception1 | Exception2 $e) {
+       echo get_class($e) . PHP_EOL;
+} catch(Exception3 | Exception4 $e) {
+       echo get_class($e) . PHP_EOL;
+} finally {
+       echo 'FINALLY' . PHP_EOL;
+}
+?>
+--EXPECT--
+TRY
+Exception3
+FINALLY
+
diff --git a/Zend/tests/try/try_multicatch_007.phpt b/Zend/tests/try/try_multicatch_007.phpt
new file mode 100644 (file)
index 0000000..aa073b0
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Catch second exception in the second multicatch
+--FILE--
+<?php
+require_once __DIR__ . '/exceptions.inc';
+
+try {
+       echo 'TRY' . PHP_EOL;
+       throw new Exception4;
+} catch(Exception1 | Exception2 $e) {
+       echo get_class($e) . PHP_EOL;
+} catch(Exception3 | Exception4 $e) {
+       echo get_class($e) . PHP_EOL;
+} finally {
+       echo 'FINALLY' . PHP_EOL;
+}
+?>
+--EXPECT--
+TRY
+Exception4
+FINALLY
+