com php-src: Move try/catch/finally tests to common directory: Zend/tests/catch_002.phpt Zend/tests/catch_00 3.phpt Zend/tests/catch_004.phpt
Zend/tests/c atch_finally_001.phpt Zend/tests/catch_finally _002.phpt Zend/tests/catch_finally_003. phpt Zend/tests/catch_finally_004.phpt Zend/tes
ts/catch_finally_005.phpt Zend/tests/catch_fina lly_006.phpt Zend/tests/finally_goto_001 .phpt Zend/tests/finally_goto_002.phpt Zend/t
ests/finally_goto_003.phpt Zend/t
| From: | Nikita Popov | Date: | Fri, 10 Jul 2015 11:35:14 +0000 |
| Subject: | com php-src: Move try/catch/finally tests to common directory: Zend/tests/catch_002.phpt Zend/tests/catch_00 3.phpt Zend/tests/catch_004.phpt Zend/tests/c atch_finally_001.phpt Zend/tests/catch_finally _002.phpt Zend/tests/catch_finally_003. phpt Zend/tests/catch_finally_004.phpt Zend/tes ts/catch_finally_005.phpt Zend/tests/catch_fina lly_006.phpt Zend/tests/finally_goto_001 .phpt Zend/tests/finally_goto_002.phpt Zend/t ests/finally_goto_003.phpt Zend/t |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87910@lists.php.net to get a copy of this message | ||
Commit: 25d327e53fc1ac3e36483124fbf168a86ab0cfb9
Author: Nikita Popov <nikic@php.net> Fri, 10 Jul 2015 13:35:14 +0200
Parents: 725fed49029e4c6a00305173d46be410cfdb59b8
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=25d327e53fc1ac3e36483124fbf168a86ab0cfb9
Log:
Move try/catch/finally tests to common directory
Changed paths:
D Zend/tests/catch_002.phpt
D Zend/tests/catch_003.phpt
D Zend/tests/catch_004.phpt
D Zend/tests/catch_finally_001.phpt
D Zend/tests/catch_finally_002.phpt
D Zend/tests/catch_finally_003.phpt
D Zend/tests/catch_finally_004.phpt
D Zend/tests/catch_finally_005.phpt
D Zend/tests/catch_finally_006.phpt
D Zend/tests/finally_goto_001.phpt
D Zend/tests/finally_goto_002.phpt
D Zend/tests/finally_goto_003.phpt
D Zend/tests/finally_goto_004.phpt
A Zend/tests/try/catch_002.phpt
A Zend/tests/try/catch_003..phpt
A Zend/tests/try/catch_004.phpt
A Zend/tests/try/catch_finally_001.phpt
A Zend/tests/try/catch_finally_002.phpt
A Zend/tests/try/catch_finally_003.phpt
A Zend/tests/try/catch_finally_004.phpt
A Zend/tests/try/catch_finally_005.phpt
A Zend/tests/try/catch_finally_006.phpt
A Zend/tests/try/finally_goto_001.phpt
A Zend/tests/try/finally_goto_002.phpt
A Zend/tests/try/finally_goto_003.phpt
A Zend/tests/try/finally_goto_004.phpt
A Zend/tests/try/try_catch_finally_001.phpt
A Zend/tests/try/try_catch_finally_002.phpt
A Zend/tests/try/try_catch_finally_003.phpt
A Zend/tests/try/try_catch_finally_004.phpt
A Zend/tests/try/try_catch_finally_005.phpt
A Zend/tests/try/try_catch_finally_006.phpt
A Zend/tests/try/try_catch_finally_007.phpt
A Zend/tests/try/try_finally_001.phpt
A Zend/tests/try/try_finally_002.phpt
A Zend/tests/try/try_finally_003.phpt
A Zend/tests/try/try_finally_004.phpt
A Zend/tests/try/try_finally_005.phpt
A Zend/tests/try/try_finally_006.phpt
A Zend/tests/try/try_finally_007.phpt
A Zend/tests/try/try_finally_008.phpt
A Zend/tests/try/try_finally_009.phpt
A Zend/tests/try/try_finally_010.phpt
A Zend/tests/try/try_finally_011.phpt
A Zend/tests/try/try_finally_012.phpt
D Zend/tests/try_catch_finally_001.phpt
D Zend/tests/try_catch_finally_002.phpt
D Zend/tests/try_catch_finally_003.phpt
D Zend/tests/try_catch_finally_004.phpt
D Zend/tests/try_catch_finally_005.phpt
D Zend/tests/try_catch_finally_006.phpt
D Zend/tests/try_catch_finally_007.phpt
D Zend/tests/try_finally_001.phpt
D Zend/tests/try_finally_002.phpt
D Zend/tests/try_finally_003.phpt
D Zend/tests/try_finally_004.phpt
D Zend/tests/try_finally_005.phpt
D Zend/tests/try_finally_006.phpt
D Zend/tests/try_finally_007.phpt
D Zend/tests/try_finally_008.phpt
D Zend/tests/try_finally_009.phpt
D Zend/tests/try_finally_010.phpt
D Zend/tests/try_finally_011.phpt
D Zend/tests/try_finally_012.phpt
diff --git a/Zend/tests/catch_002.phpt b/Zend/tests/catch_002.phpt deleted file mode 100644 index 11d736a..0000000 --- a/Zend/tests/catch_002.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Catching an exception in a constructor ---FILE-- -<?php - -class MyObject -{ - function __construct() - { - throw new Exception(); - echo __METHOD__ . "() Must not be reached\n"; - } - - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } -} - -try -{ - new MyObject(); -} -catch(Exception $e) -{ - echo "Caught\n"; -} - -?> -===DONE=== ---EXPECT-- -Caught -===DONE=== diff --git a/Zend/tests/catch_003.phpt b/Zend/tests/catch_003.phpt deleted file mode 100644 index 414d50f..0000000 --- a/Zend/tests/catch_003.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Catching an exception in a constructor fired form a static method ---FILE-- -<?php - -class MyObject -{ - function fail() - { - throw new Exception(); - } - - function __construct() - { - self::fail(); - echo __METHOD__ . "() Must not be reached\n"; - } - - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } -} - -try -{ - new MyObject(); -} -catch(Exception $e) -{ - echo "Caught\n"; -} - -?> -===DONE=== ---EXPECT-- -Caught -===DONE=== diff --git a/Zend/tests/catch_004.phpt b/Zend/tests/catch_004.phpt deleted file mode 100644 index 54920b8..0000000 --- a/Zend/tests/catch_004.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Catching an exception in a constructor inside a static method ---FILE-- -<?php - -class MyObject -{ - function fail() - { - throw new Exception(); - } - - function __construct() - { - self::fail(); - echo __METHOD__ . "() Must not be reached\n"; - } - - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } - - static function test() - { - try - { - new MyObject(); - } - catch(Exception $e) - { - echo "Caught\n"; - } - } -} - -MyObject::test(); - -?> -===DONE=== ---EXPECT-- -Caught -===DONE=== diff --git a/Zend/tests/catch_finally_001.phpt b/Zend/tests/catch_finally_001.phpt deleted file mode 100644 index 0c3f597..0000000 --- a/Zend/tests/catch_finally_001.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Try catch finally (basic test) ---FILE-- -<?php -function foo ($throw = FALSE) { - try { - echo "try\n"; - if ($throw) { - throw new Exception("ex"); - } - } catch (Exception $e) { - echo "catch\n"; - } finally { - echo "finally\n"; - } - - echo "end\n"; -} - -foo(); -echo "\n"; -foo(true); -?> ---EXPECTF-- -try -finally -end - -try -catch -finally -end diff --git a/Zend/tests/catch_finally_002.phpt b/Zend/tests/catch_finally_002.phpt deleted file mode 100644 index c54477f..0000000 --- a/Zend/tests/catch_finally_002.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Try catch finally (basic test with return) ---FILE-- -<?php -function foo () { - try { - echo "try\n"; - return 1; - } catch (Exception $e) { - } finally { - echo "finally\n"; - } - return 2; -} - -var_dump(foo()); -?> ---EXPECTF-- -try -finally -int(1) diff --git a/Zend/tests/catch_finally_003.phpt b/Zend/tests/catch_finally_003.phpt deleted file mode 100644 index 24e468d..0000000 --- a/Zend/tests/catch_finally_003.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Try catch finally (with multi-returns) ---FILE-- -<?php -function dummy($msg) { - var_dump($msg); -} - -function foo ($a) { - try { - dummy("try"); - return $a; - } catch (Exception $e) { - throw $e; - } finally { - dummy("finally"); - return "finally"; - } - return "end"; -} - -function &bar($a) { - try { - echo "try\n"; - throw new Exception("ex"); - } catch (Exception $e) { - } finally { - return $a; - } - return ($c = "end"); -} -var_dump(foo("para")); -var_dump(bar("para")); -?> ---EXPECTF-- -string(3) "try" -string(7) "finally" -string(7) "finally" -try -string(4) "para" diff --git a/Zend/tests/catch_finally_004.phpt b/Zend/tests/catch_finally_004.phpt deleted file mode 100644 index a2c22be..0000000 --- a/Zend/tests/catch_finally_004.phpt +++ /dev/null @@ -1,41 +0,0 @@ ---TEST-- -Try catch finally (nesting try-catch-finally) ---FILE-- -<?php - -function throw_exception($msg) { - throw new Exception($msg); -} - -function foo (&$ex) { - try { - echo "1"; - try { - echo "2"; - throw_exception("try"); - } catch (Exception $e) { - echo "3"; - throw_exception("catch"); - } finally { - echo "4"; - throw_exception("finally"); - } - } catch (Exception $e) { - $ex = $e; - echo "3"; - } finally { - echo "2"; - } - return 1; -} - -var_dump(foo($ex)); - -do { - var_dump($ex->getMessage()); -} while ($ex = $ex->getPrevious()); -?> ---EXPECT-- -123432int(1) -string(7) "finally" -string(5) "catch" diff --git a/Zend/tests/catch_finally_005.phpt b/Zend/tests/catch_finally_005.phpt deleted file mode 100644 index c2fd55d..0000000 --- a/Zend/tests/catch_finally_005.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Try catch finally (with multi-returns and exception) ---FILE-- -<?php -function foo ($a) { - try { - throw new Exception("ex"); - } catch (PdoException $e) { - die("error"); - } catch (Exception $e) { - return 2; - } finally { - return 3; - } - return 1; -} - -var_dump(foo("para")); -?> ---EXPECTF-- -int(3) diff --git a/Zend/tests/catch_finally_006.phpt b/Zend/tests/catch_finally_006.phpt deleted file mode 100644 index 216219b..0000000 --- a/Zend/tests/catch_finally_006.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Try catch finally (re-throw exception in catch block) ---FILE-- -<?php -function foo ($a) { - try { - throw new Exception("ex"); - } catch (Exception $e) { - var_dump($a); - throw $e; - } finally { - var_dump("finally"); - return "return"; - } - return 1; -} - -try { - var_dump(foo("para")); -} catch (Exception $e) { - "caught exception" . PHP_EOL; - var_dump($e->getMessage()); -} -?> ---EXPECT-- -string(4) "para" -string(7) "finally" -string(6) "return" diff --git a/Zend/tests/finally_goto_001.phpt b/Zend/tests/finally_goto_001.phpt deleted file mode 100644 index 990f78d..0000000 --- a/Zend/tests/finally_goto_001.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -jmp into a finally block 01 ---FILE-- -<?php -function foo() { - goto test; - try { - } finally { -test: - } -} -?> ---EXPECTF-- -Fatal error: jump into a finally block is disallowed in %sfinally_goto_001.php on line %d diff --git a/Zend/tests/finally_goto_002.phpt b/Zend/tests/finally_goto_002.phpt deleted file mode 100644 index a6bd9e3..0000000 --- a/Zend/tests/finally_goto_002.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -jmp into a finally block 02 ---FILE-- -<?php -function foo() { - try { - goto test; - } finally { -test: - } -} -?> ---EXPECTF-- -Fatal error: jump into a finally block is disallowed in %sfinally_goto_002.php on line %d diff --git a/Zend/tests/finally_goto_003.phpt b/Zend/tests/finally_goto_003.phpt deleted file mode 100644 index 8529ff7..0000000 --- a/Zend/tests/finally_goto_003.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -jmp into a finally block 03 ---FILE-- -<?php -function foo() { - try { - } finally { - goto test; -test: - } -} -echo "okey"; -?> ---EXPECTF-- -okey diff --git a/Zend/tests/finally_goto_004.phpt b/Zend/tests/finally_goto_004.phpt deleted file mode 100644 index d88ceed..0000000 --- a/Zend/tests/finally_goto_004.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -jmp into a finally block 03 ---FILE-- -<?php -function foo() { - try { - } finally { -test: - } - goto test; -} -?> ---EXPECTF-- -Fatal error: jump into a finally block is disallowed in %sfinally_goto_004.php on line %d diff --git a/Zend/tests/try/catch_002.phpt b/Zend/tests/try/catch_002.phpt new file mode 100644 index 0000000..11d736a --- /dev/null +++ b/Zend/tests/try/catch_002.phpt @@ -0,0 +1,33 @@ +--TEST-- +Catching an exception in a constructor +--FILE-- +<?php + +class MyObject +{ + function __construct() + { + throw new Exception(); + echo __METHOD__ . "() Must not be reached\n"; + } + + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } +} + +try +{ + new MyObject(); +} +catch(Exception $e) +{ + echo "Caught\n"; +} + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/try/catch_003.phpt b/Zend/tests/try/catch_003.phpt new file mode 100644 index 0000000..414d50f --- /dev/null +++ b/Zend/tests/try/catch_003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Catching an exception in a constructor fired form a static method +--FILE-- +<?php + +class MyObject +{ + function fail() + { + throw new Exception(); + } + + function __construct() + { + self::fail(); + echo __METHOD__ . "() Must not be reached\n"; + } + + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } +} + +try +{ + new MyObject(); +} +catch(Exception $e) +{ + echo "Caught\n"; +} + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/try/catch_004.phpt b/Zend/tests/try/catch_004.phpt new file mode 100644 index 0000000..54920b8 --- /dev/null +++ b/Zend/tests/try/catch_004.phpt @@ -0,0 +1,43 @@ +--TEST-- +Catching an exception in a constructor inside a static method +--FILE-- +<?php + +class MyObject +{ + function fail() + { + throw new Exception(); + } + + function __construct() + { + self::fail(); + echo __METHOD__ . "() Must not be reached\n"; + } + + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } + + static function test() + { + try + { + new MyObject(); + } + catch(Exception $e) + { + echo "Caught\n"; + } + } +} + +MyObject::test(); + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/try/catch_finally_001.phpt b/Zend/tests/try/catch_finally_001.phpt new file mode 100644 index 0000000..0c3f597 --- /dev/null +++ b/Zend/tests/try/catch_finally_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +Try catch finally (basic test) +--FILE-- +<?php +function foo ($throw = FALSE) { + try { + echo "try\n"; + if ($throw) { + throw new Exception("ex"); + } + } catch (Exception $e) { + echo "catch\n"; + } finally { + echo "finally\n"; + } + + echo "end\n"; +} + +foo(); +echo "\n"; +foo(true); +?> +--EXPECTF-- +try +finally +end + +try +catch +finally +end diff --git a/Zend/tests/try/catch_finally_002.phpt b/Zend/tests/try/catch_finally_002.phpt new file mode 100644 index 0000000..c54477f --- /dev/null +++ b/Zend/tests/try/catch_finally_002.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try catch finally (basic test with return) +--FILE-- +<?php +function foo () { + try { + echo "try\n"; + return 1; + } catch (Exception $e) { + } finally { + echo "finally\n"; + } + return 2; +} + +var_dump(foo()); +?> +--EXPECTF-- +try +finally +int(1) diff --git a/Zend/tests/try/catch_finally_003.phpt b/Zend/tests/try/catch_finally_003.phpt new file mode 100644 index 0000000..24e468d --- /dev/null +++ b/Zend/tests/try/catch_finally_003.phpt @@ -0,0 +1,40 @@ +--TEST-- +Try catch finally (with multi-returns) +--FILE-- +<?php +function dummy($msg) { + var_dump($msg); +} + +function foo ($a) { + try { + dummy("try"); + return $a; + } catch (Exception $e) { + throw $e; + } finally { + dummy("finally"); + return "finally"; + } + return "end"; +} + +function &bar($a) { + try { + echo "try\n"; + throw new Exception("ex"); + } catch (Exception $e) { + } finally { + return $a; + } + return ($c = "end"); +} +var_dump(foo("para")); +var_dump(bar("para")); +?> +--EXPECTF-- +string(3) "try" +string(7) "finally" +string(7) "finally" +try +string(4) "para" diff --git a/Zend/tests/try/catch_finally_004.phpt b/Zend/tests/try/catch_finally_004.phpt new file mode 100644 index 0000000..a2c22be --- /dev/null +++ b/Zend/tests/try/catch_finally_004.phpt @@ -0,0 +1,41 @@ +--TEST-- +Try catch finally (nesting try-catch-finally) +--FILE-- +<?php + +function throw_exception($msg) { + throw new Exception($msg); +} + +function foo (&$ex) { + try { + echo "1"; + try { + echo "2"; + throw_exception("try"); + } catch (Exception $e) { + echo "3"; + throw_exception("catch"); + } finally { + echo "4"; + throw_exception("finally"); + } + } catch (Exception $e) { + $ex = $e; + echo "3"; + } finally { + echo "2"; + } + return 1; +} + +var_dump(foo($ex)); + +do { + var_dump($ex->getMessage()); +} while ($ex = $ex->getPrevious()); +?> +--EXPECT-- +123432int(1) +string(7) "finally" +string(5) "catch" diff --git a/Zend/tests/try/catch_finally_005.phpt b/Zend/tests/try/catch_finally_005.phpt new file mode 100644 index 0000000..c2fd55d --- /dev/null +++ b/Zend/tests/try/catch_finally_005.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try catch finally (with multi-returns and exception) +--FILE-- +<?php +function foo ($a) { + try { + throw new Exception("ex"); + } catch (PdoException $e) { + die("error"); + } catch (Exception $e) { + return 2; + } finally { + return 3; + } + return 1; +} + +var_dump(foo("para")); +?> +--EXPECTF-- +int(3) diff --git a/Zend/tests/try/catch_finally_006.phpt b/Zend/tests/try/catch_finally_006.phpt new file mode 100644 index 0000000..216219b --- /dev/null +++ b/Zend/tests/try/catch_finally_006.phpt @@ -0,0 +1,28 @@ +--TEST-- +Try catch finally (re-throw exception in catch block) +--FILE-- +<?php +function foo ($a) { + try { + throw new Exception("ex"); + } catch (Exception $e) { + var_dump($a); + throw $e; + } finally { + var_dump("finally"); + return "return"; + } + return 1; +} + +try { + var_dump(foo("para")); +} catch (Exception $e) { + "caught exception" . PHP_EOL; + var_dump($e->getMessage()); +} +?> +--EXPECT-- +string(4) "para" +string(7) "finally" +string(6) "return" diff --git a/Zend/tests/try/finally_goto_001.phpt b/Zend/tests/try/finally_goto_001.phpt new file mode 100644 index 0000000..990f78d --- /dev/null +++ b/Zend/tests/try/finally_goto_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +jmp into a finally block 01 +--FILE-- +<?php +function foo() { + goto test; + try { + } finally { +test: + } +} +?> +--EXPECTF-- +Fatal error: jump into a finally block is disallowed in %sfinally_goto_001.php on line %d diff --git a/Zend/tests/try/finally_goto_002.phpt b/Zend/tests/try/finally_goto_002.phpt new file mode 100644 index 0000000..a6bd9e3 --- /dev/null +++ b/Zend/tests/try/finally_goto_002.phpt @@ -0,0 +1,14 @@ +--TEST-- +jmp into a finally block 02 +--FILE-- +<?php +function foo() { + try { + goto test; + } finally { +test: + } +} +?> +--EXPECTF-- +Fatal error: jump into a finally block is disallowed in %sfinally_goto_002.php on line %d diff --git a/Zend/tests/try/finally_goto_003.phpt b/Zend/tests/try/finally_goto_003.phpt new file mode 100644 index 0000000..8529ff7 --- /dev/null +++ b/Zend/tests/try/finally_goto_003.phpt @@ -0,0 +1,15 @@ +--TEST-- +jmp into a finally block 03 +--FILE-- +<?php +function foo() { + try { + } finally { + goto test; +test: + } +} +echo "okey"; +?> +--EXPECTF-- +okey diff --git a/Zend/tests/try/finally_goto_004.phpt b/Zend/tests/try/finally_goto_004.phpt new file mode 100644 index 0000000..d88ceed --- /dev/null +++ b/Zend/tests/try/finally_goto_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +jmp into a finally block 03 +--FILE-- +<?php +function foo() { + try { + } finally { +test: + } + goto test; +} +?> +--EXPECTF-- +Fatal error: jump into a finally block is disallowed in %sfinally_goto_004.php on line %d diff --git a/Zend/tests/try/try_catch_finally_001.phpt b/Zend/tests/try/try_catch_finally_001.phpt new file mode 100644 index 0000000..3d478f4 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_001.phpt @@ -0,0 +1,36 @@ +--TEST-- +Try catch finally +--FILE-- +<?php + +class AE extends Exception {}; +class BE extends Exception {}; + +function foo () { + try { + try { + try { + throw new Exception("try"); + } catch (AE $e) { + echo "0"; + die("error"); + } finally { + echo "1"; + } + } finally { + echo "2"; + } + } catch (BE $e) { + die("error"); + } catch (Exception $e) { + echo "3"; + } finally { + echo "4"; + } + return 1; +} + +var_dump(foo()); +?> +--EXPECTF-- +1234int(1) diff --git a/Zend/tests/try/try_catch_finally_002.phpt b/Zend/tests/try/try_catch_finally_002.phpt new file mode 100644 index 0000000..79efcb3 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_002.phpt @@ -0,0 +1,42 @@ +--TEST-- +Try catch finally catch(multi catch blocks) +--FILE-- +<?php + +class AE extends Exception {}; +class BE extends Exception {}; + +function foo () { + try { + try { + try { + try { + echo "1"; + throw new Exception("try"); + } catch (AE $e) { + die("error"); + } finally { + echo "2"; + } + } finally { + echo "3"; + } + } catch (BE $e) { + die("error"); + } finally { + echo "4"; + } + } catch (Exception $e) { + echo "5"; + } catch (AE $e) { + die("error"); + } finally { + echo "6"; + } + return 7; +} + +var_dump(foo()); +?> +--EXPECTF-- +123456int(7) diff --git a/Zend/tests/try/try_catch_finally_003.phpt b/Zend/tests/try/try_catch_finally_003.phpt new file mode 100644 index 0000000..7ec8ec8 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_003.phpt @@ -0,0 +1,36 @@ +--TEST-- +Try catch finally (multi catch blocks with return) +--FILE-- +<?php + +class AE extends Exception {}; +class BE extends Exception {}; + +function foo () { + try { + try { + try { + throw new Exception("try"); + } catch (AE $e) { + die("error"); + } finally { + echo "1"; + } + } finally { + echo "2"; + } + } catch (BE $e) { + die("error"); + } catch (Exception $e) { + echo "3"; + } finally { + echo "4"; + return 4; + } + return 5; +} + +var_dump(foo()); +?> +--EXPECTF-- +1234int(4) diff --git a/Zend/tests/try/try_catch_finally_004.phpt b/Zend/tests/try/try_catch_finally_004.phpt new file mode 100644 index 0000000..eb8d096 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_004.phpt @@ -0,0 +1,30 @@ +--TEST-- +Try catch finally (re-throw exception in catch block) +--CREDITS-- +adoy +--FILE-- +<?php +function dummy($msg) { + var_dump($msg); +} +try { + try { + var_dump("try"); + return; + } catch (Exception $e) { + dummy("catch"); + throw $e; + } finally { + dummy("finally"); + } +} catch (Exception $e) { + dummy("catch2"); +} finally { + dummy("finally2"); +} +var_dump("end"); +?> +--EXPECTF-- +string(3) "try" +string(7) "finally" +string(8) "finally2" diff --git a/Zend/tests/try/try_catch_finally_005.phpt b/Zend/tests/try/try_catch_finally_005.phpt new file mode 100644 index 0000000..dafeb6b --- /dev/null +++ b/Zend/tests/try/try_catch_finally_005.phpt @@ -0,0 +1,52 @@ +--TEST-- +Try catch finally (break / cont in try block) +--CREDITS-- +adoy +--FILE-- +<?php +for ($i = 0; $i < 100 ; $i ++) { + try { + break; + } finally { + var_dump("break"); + } +} + + +for ($i = 0; $i < 2; $i ++) { + try { + continue; + } finally { + var_dump("continue1"); + } +} + +for ($i = 0; $i < 3; $i ++) { + try { + try { + continue; + } finally { + var_dump("continue2"); + if ($i == 1) { + throw new Exception("continue exception"); + } + } + } catch (Exception $e) { + var_dump("cactched"); + } finally { + var_dump("finally"); + } +} + +?> +--EXPECTF-- +string(5) "break" +string(9) "continue1" +string(9) "continue1" +string(9) "continue2" +string(7) "finally" +string(9) "continue2" +string(8) "cactched" +string(7) "finally" +string(9) "continue2" +string(7) "finally" diff --git a/Zend/tests/try/try_catch_finally_006.phpt b/Zend/tests/try/try_catch_finally_006.phpt new file mode 100644 index 0000000..dab6af6 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_006.phpt @@ -0,0 +1,39 @@ +--TEST-- +Try catch finally (goto in try/catch block) +--CREDITS-- +adoy +--FILE-- +<?php +function foo($ex = NULL) { + try { + try { + goto label; + } finally { + var_dump("finally1"); + if ($ex) throw $ex; + } + } catch (Exception $e) { + var_dump("catched"); + if ($ex) return "return1"; + } finally { + var_dump("finally2"); + } + +label: + var_dump("label"); + return "return2"; +} + +var_dump(foo()); +var_dump(foo(new Exception())); + +?> +--EXPECTF-- +string(8) "finally1" +string(8) "finally2" +string(5) "label" +string(7) "return2" +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(7) "return1" diff --git a/Zend/tests/try/try_catch_finally_007.phpt b/Zend/tests/try/try_catch_finally_007.phpt new file mode 100644 index 0000000..ad33c68 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_007.phpt @@ -0,0 +1,46 @@ +--TEST-- +Try catch finally (goto in try/catch block) +--CREDITS-- +adoy +--FILE-- +<?php +function foo($ret = FALSE) { + try { + try { + do { + goto label; + } while(0); + foreach (array() as $val) { + continue; + } + } finally { + var_dump("finally1"); + throw new Exception("exception"); + } + } catch (Exception $e) { + goto local; +local: + var_dump("catched"); + if ($ret) return "return"; + } finally { + var_dump("finally2"); + } + +label: + var_dump("label"); +} + +var_dump(foo()); +var_dump(foo(true)); + +?> +--EXPECTF-- +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(5) "label" +NULL +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(6) "return" diff --git a/Zend/tests/try/try_finally_001.phpt b/Zend/tests/try/try_finally_001.phpt new file mode 100644 index 0000000..33744d0 --- /dev/null +++ b/Zend/tests/try/try_finally_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +Try finally (basic test) +--FILE-- +<?php +function foo ($a) { + try { + throw new Exception("ex"); + } finally { + var_dump($a); + } +} + +foo("finally"); +?> +--EXPECTF-- +string(7) "finally" + +Fatal error: Uncaught Exception: ex %s +Stack trace: +#0 %stry_finally_001.php(%d): foo('finally') +#1 {main} + thrown in %stry_finally_001.php on line %d diff --git a/Zend/tests/try/try_finally_002.phpt b/Zend/tests/try/try_finally_002.phpt new file mode 100644 index 0000000..99a34f6 --- /dev/null +++ b/Zend/tests/try/try_finally_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +Try finally (re-throw exception in finally block) +--FILE-- +<?php +function foo () { + try { + throw new Exception("try"); + } finally { + throw new Exception("finally"); + } +} + +try { + foo(); +} catch (Exception $e) { + do { + var_dump($e->getMessage()); + } while ($e = $e->getPrevious()); +} +?> +--EXPECT-- +string(7) "finally" +string(3) "try" diff --git a/Zend/tests/try/try_finally_003.phpt b/Zend/tests/try/try_finally_003.phpt new file mode 100644 index 0000000..b0fee7c --- /dev/null +++ b/Zend/tests/try/try_finally_003.phpt @@ -0,0 +1,27 @@ +--TEST-- +Try finally (call sequence test) +--FILE-- +<?php +function foo () { + try { + echo "1"; + try { + echo "2"; + throw new Exception("ex"); + } finally { + echo "3"; + } + } finally { + echo "4"; + } +} + +foo(); +?> +--EXPECTF-- +1234 +Fatal error: Uncaught Exception: ex %s +Stack trace: +#0 %stry_finally_003.php(%d): foo() +#1 {main} + thrown in %stry_finally_003.php on line %d diff --git a/Zend/tests/try/try_finally_004.phpt b/Zend/tests/try/try_finally_004.phpt new file mode 100644 index 0000000..08930a4 --- /dev/null +++ b/Zend/tests/try/try_finally_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +Try finally (without catch/finally block) +--FILE-- +<?php +function foo () { + try { + echo "3"; + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: Cannot use try without catch or finally in %stry_finally_004.php on line %d diff --git a/Zend/tests/try/try_finally_005.phpt b/Zend/tests/try/try_finally_005.phpt new file mode 100644 index 0000000..8664d6b --- /dev/null +++ b/Zend/tests/try/try_finally_005.phpt @@ -0,0 +1,17 @@ +--TEST-- +Try finally (with long goto) +--FILE-- +<?php +function foo () { + try { + } finally { + goto label; + } +label: + return 1; +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_005.php on line %d diff --git a/Zend/tests/try/try_finally_006.phpt b/Zend/tests/try/try_finally_006.phpt new file mode 100644 index 0000000..f53e6b5 --- /dev/null +++ b/Zend/tests/try/try_finally_006.phpt @@ -0,0 +1,26 @@ +--TEST-- +Try finally (with near goto) +--FILE-- +<?php +function foo () { + $jmp = 1; + try { + } finally { +previous: + if ($jmp) { + goto label; + echo "dummy"; +label: + echo "label\n"; + $jmp = 0; + goto previous; + } + echo "okey"; + } +} + +foo(); +?> +--EXPECTF-- +label +okey diff --git a/Zend/tests/try/try_finally_007.phpt b/Zend/tests/try/try_finally_007.phpt new file mode 100644 index 0000000..6349374 --- /dev/null +++ b/Zend/tests/try/try_finally_007.phpt @@ -0,0 +1,22 @@ +--TEST-- +Try finally (with goto previous label) +--FILE-- +<?php +function foo () { + try { +label: + echo "label"; + try { + } finally { + goto label; + echo "dummy"; + } + } catch (Exception $e) { + } finally { + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_007.php on line %d diff --git a/Zend/tests/try/try_finally_008.phpt b/Zend/tests/try/try_finally_008.phpt new file mode 100644 index 0000000..cee37ae --- /dev/null +++ b/Zend/tests/try/try_finally_008.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try finally (with break in do...while) +--FILE-- +<?php +function foo () { + do { + try { + try { + } finally { + break; + } + } catch (Exception $e) { + } finally { + } + } while (0); +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_008.php on line %d diff --git a/Zend/tests/try/try_finally_009.phpt b/Zend/tests/try/try_finally_009.phpt new file mode 100644 index 0000000..b29930a --- /dev/null +++ b/Zend/tests/try/try_finally_009.phpt @@ -0,0 +1,23 @@ +--TEST-- +Try finally (with for continue) +--FILE-- +<?php +function foo () { + for($i = 0; $i < 5; $i++) { + do { + try { + try { + } finally { + } + } catch (Exception $e) { + } finally { + continue; + } + } while (0); + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_009.php on line %d diff --git a/Zend/tests/try/try_finally_010.phpt b/Zend/tests/try/try_finally_010.phpt new file mode 100644 index 0000000..91eb782 --- /dev/null +++ b/Zend/tests/try/try_finally_010.phpt @@ -0,0 +1,30 @@ +--TEST-- +Try finally (function call in the finally block after exception) +--FILE-- +<?php +function foo() { + echo "4"; +} +function bar() { + try { + echo "2"; + throw new Exception(); + echo "x"; + } catch (MyEx $ex) { + echo "x"; + } finally { + echo "3"; + foo(); + echo "5"; + } +} +try { + echo "1"; + bar(); + echo "x"; +} catch (Exception $ex) { + echo "6"; +} +echo "\n"; +--EXPECT-- +123456 diff --git a/Zend/tests/try/try_finally_011.phpt b/Zend/tests/try/try_finally_011.phpt new file mode 100644 index 0000000..8a9dc62 --- /dev/null +++ b/Zend/tests/try/try_finally_011.phpt @@ -0,0 +1,15 @@ +--TEST-- +Try finally (segfault with empty break) +--FILE-- +<?php +function foo () { + try { + break; + } finally { + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: 'break' not in the 'loop' or 'switch' context in %stry_finally_011.php on line %d diff --git a/Zend/tests/try/try_finally_012.phpt b/Zend/tests/try/try_finally_012.phpt new file mode 100644 index 0000000..32fec7a --- /dev/null +++ b/Zend/tests/try/try_finally_012.phpt @@ -0,0 +1,32 @@ +--TEST-- +Try finally (exception in "return" statement) +--FILE-- +<?php +class A { + public $x = 1; + public $y = 2; + function __destruct() { + throw new Exception(); + } +} +function foo() { + foreach(new A() as $a) { + try { + return $a; + } catch (Exception $e) { + echo "exception in foo\n"; + } finally { + echo "finally\n"; + } + } +} +try { + foo(); +} catch (Exception $e) { + echo "exception in main\n"; +} +?> +--EXPECT-- +finally +exception in main + diff --git a/Zend/tests/try_catch_finally_001.phpt b/Zend/tests/try_catch_finally_001.phpt deleted file mode 100644 index 3d478f4..0000000 --- a/Zend/tests/try_catch_finally_001.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Try catch finally ---FILE-- -<?php - -class AE extends Exception {}; -class BE extends Exception {}; - -function foo () { - try { - try { - try { - throw new Exception("try"); - } catch (AE $e) { - echo "0"; - die("error"); - } finally { - echo "1"; - } - } finally { - echo "2"; - } - } catch (BE $e) { - die("error"); - } catch (Exception $e) { - echo "3"; - } finally { - echo "4"; - } - return 1; -} - -var_dump(foo()); -?> ---EXPECTF-- -1234int(1) diff --git a/Zend/tests/try_catch_finally_002.phpt b/Zend/tests/try_catch_finally_002.phpt deleted file mode 100644 index 79efcb3..0000000 --- a/Zend/tests/try_catch_finally_002.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Try catch finally catch(multi catch blocks) ---FILE-- -<?php - -class AE extends Exception {}; -class BE extends Exception {}; - -function foo () { - try { - try { - try { - try { - echo "1"; - throw new Exception("try"); - } catch (AE $e) { - die("error"); - } finally { - echo "2"; - } - } finally { - echo "3"; - } - } catch (BE $e) { - die("error"); - } finally { - echo "4"; - } - } catch (Exception $e) { - echo "5"; - } catch (AE $e) { - die("error"); - } finally { - echo "6"; - } - return 7; -} - -var_dump(foo()); -?> ---EXPECTF-- -123456int(7) diff --git a/Zend/tests/try_catch_finally_003.phpt b/Zend/tests/try_catch_finally_003.phpt deleted file mode 100644 index 7ec8ec8..0000000 --- a/Zend/tests/try_catch_finally_003.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Try catch finally (multi catch blocks with return) ---FILE-- -<?php - -class AE extends Exception {}; -class BE extends Exception {}; - -function foo () { - try { - try { - try { - throw new Exception("try"); - } catch (AE $e) { - die("error"); - } finally { - echo "1"; - } - } finally { - echo "2"; - } - } catch (BE $e) { - die("error"); - } catch (Exception $e) { - echo "3"; - } finally { - echo "4"; - return 4; - } - return 5; -} - -var_dump(foo()); -?> ---EXPECTF-- -1234int(4) diff --git a/Zend/tests/try_catch_finally_004.phpt b/Zend/tests/try_catch_finally_004.phpt deleted file mode 100644 index eb8d096..0000000 --- a/Zend/tests/try_catch_finally_004.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Try catch finally (re-throw exception in catch block) ---CREDITS-- -adoy ---FILE-- -<?php -function dummy($msg) { - var_dump($msg); -} -try { - try { - var_dump("try"); - return; - } catch (Exception $e) { - dummy("catch"); - throw $e; - } finally { - dummy("finally"); - } -} catch (Exception $e) { - dummy("catch2"); -} finally { - dummy("finally2"); -} -var_dump("end"); -?> ---EXPECTF-- -string(3) "try" -string(7) "finally" -string(8) "finally2" diff --git a/Zend/tests/try_catch_finally_005.phpt b/Zend/tests/try_catch_finally_005.phpt deleted file mode 100644 index dafeb6b..0000000 --- a/Zend/tests/try_catch_finally_005.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -Try catch finally (break / cont in try block) ---CREDITS-- -adoy ---FILE-- -<?php -for ($i = 0; $i < 100 ; $i ++) { - try { - break; - } finally { - var_dump("break"); - } -} - - -for ($i = 0; $i < 2; $i ++) { - try { - continue; - } finally { - var_dump("continue1"); - } -} - -for ($i = 0; $i < 3; $i ++) { - try { - try { - continue; - } finally { - var_dump("continue2"); - if ($i == 1) { - throw new Exception("continue exception"); - } - } - } catch (Exception $e) { - var_dump("cactched"); - } finally { - var_dump("finally"); - } -} - -?> ---EXPECTF-- -string(5) "break" -string(9) "continue1" -string(9) "continue1" -string(9) "continue2" -string(7) "finally" -string(9) "continue2" -string(8) "cactched" -string(7) "finally" -string(9) "continue2" -string(7) "finally" diff --git a/Zend/tests/try_catch_finally_006.phpt b/Zend/tests/try_catch_finally_006.phpt deleted file mode 100644 index dab6af6..0000000 --- a/Zend/tests/try_catch_finally_006.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Try catch finally (goto in try/catch block) ---CREDITS-- -adoy ---FILE-- -<?php -function foo($ex = NULL) { - try { - try { - goto label; - } finally { - var_dump("finally1"); - if ($ex) throw $ex; - } - } catch (Exception $e) { - var_dump("catched"); - if ($ex) return "return1"; - } finally { - var_dump("finally2"); - } - -label: - var_dump("label"); - return "return2"; -} - -var_dump(foo()); -var_dump(foo(new Exception())); - -?> ---EXPECTF-- -string(8) "finally1" -string(8) "finally2" -string(5) "label" -string(7) "return2" -string(8) "finally1" -string(7) "catched" -string(8) "finally2" -string(7) "return1" diff --git a/Zend/tests/try_catch_finally_007.phpt b/Zend/tests/try_catch_finally_007.phpt deleted file mode 100644 index ad33c68..0000000 --- a/Zend/tests/try_catch_finally_007.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Try catch finally (goto in try/catch block) ---CREDITS-- -adoy ---FILE-- -<?php -function foo($ret = FALSE) { - try { - try { - do { - goto label; - } while(0); - foreach (array() as $val) { - continue; - } - } finally { - var_dump("finally1"); - throw new Exception("exception"); - } - } catch (Exception $e) { - goto local; -local: - var_dump("catched"); - if ($ret) return "return"; - } finally { - var_dump("finally2"); - } - -label: - var_dump("label"); -} - -var_dump(foo()); -var_dump(foo(true)); - -?> ---EXPECTF-- -string(8) "finally1" -string(7) "catched" -string(8) "finally2" -string(5) "label" -NULL -string(8) "finally1" -string(7) "catched" -string(8) "finally2" -string(6) "return" diff --git a/Zend/tests/try_finally_001.phpt b/Zend/tests/try_finally_001.phpt deleted file mode 100644 index 33744d0..0000000 --- a/Zend/tests/try_finally_001.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Try finally (basic test) ---FILE-- -<?php -function foo ($a) { - try { - throw new Exception("ex"); - } finally { - var_dump($a); - } -} - -foo("finally"); -?> ---EXPECTF-- -string(7) "finally" - -Fatal error: Uncaught Exception: ex %s -Stack trace: -#0 %stry_finally_001.php(%d): foo('finally') -#1 {main} - thrown in %stry_finally_001.php on line %d diff --git a/Zend/tests/try_finally_002.phpt b/Zend/tests/try_finally_002.phpt deleted file mode 100644 index 99a34f6..0000000 --- a/Zend/tests/try_finally_002.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Try finally (re-throw exception in finally block) ---FILE-- -<?php -function foo () { - try { - throw new Exception("try"); - } finally { - throw new Exception("finally"); - } -} - -try { - foo(); -} catch (Exception $e) { - do { - var_dump($e->getMessage()); - } while ($e = $e->getPrevious()); -} -?> ---EXPECT-- -string(7) "finally" -string(3) "try" diff --git a/Zend/tests/try_finally_003.phpt b/Zend/tests/try_finally_003.phpt deleted file mode 100644 index b0fee7c..0000000 --- a/Zend/tests/try_finally_003.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Try finally (call sequence test) ---FILE-- -<?php -function foo () { - try { - echo "1"; - try { - echo "2"; - throw new Exception("ex"); - } finally { - echo "3"; - } - } finally { - echo "4"; - } -} - -foo(); -?> ---EXPECTF-- -1234 -Fatal error: Uncaught Exception: ex %s -Stack trace: -#0 %stry_finally_003.php(%d): foo() -#1 {main} - thrown in %stry_finally_003.php on line %d diff --git a/Zend/tests/try_finally_004.phpt b/Zend/tests/try_finally_004.phpt deleted file mode 100644 index 08930a4..0000000 --- a/Zend/tests/try_finally_004.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Try finally (without catch/finally block) ---FILE-- -<?php -function foo () { - try { - echo "3"; - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: Cannot use try without catch or finally in %stry_finally_004.php on line %d diff --git a/Zend/tests/try_finally_005.phpt b/Zend/tests/try_finally_005.phpt deleted file mode 100644 index 8664d6b..0000000 --- a/Zend/tests/try_finally_005.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Try finally (with long goto) ---FILE-- -<?php -function foo () { - try { - } finally { - goto label; - } -label: - return 1; -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_005.php on line %d diff --git a/Zend/tests/try_finally_006.phpt b/Zend/tests/try_finally_006.phpt deleted file mode 100644 index f53e6b5..0000000 --- a/Zend/tests/try_finally_006.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Try finally (with near goto) ---FILE-- -<?php -function foo () { - $jmp = 1; - try { - } finally { -previous: - if ($jmp) { - goto label; - echo "dummy"; -label: - echo "label\n"; - $jmp = 0; - goto previous; - } - echo "okey"; - } -} - -foo(); -?> ---EXPECTF-- -label -okey diff --git a/Zend/tests/try_finally_007.phpt b/Zend/tests/try_finally_007.phpt deleted file mode 100644 index 6349374..0000000 --- a/Zend/tests/try_finally_007.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Try finally (with goto previous label) ---FILE-- -<?php -function foo () { - try { -label: - echo "label"; - try { - } finally { - goto label; - echo "dummy"; - } - } catch (Exception $e) { - } finally { - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_007.php on line %d diff --git a/Zend/tests/try_finally_008.phpt b/Zend/tests/try_finally_008.phpt deleted file mode 100644 index cee37ae..0000000 --- a/Zend/tests/try_finally_008.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Try finally (with break in do...while) ---FILE-- -<?php -function foo () { - do { - try { - try { - } finally { - break; - } - } catch (Exception $e) { - } finally { - } - } while (0); -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_008.php on line %d diff --git a/Zend/tests/try_finally_009.phpt b/Zend/tests/try_finally_009.phpt deleted file mode 100644 index b29930a..0000000 --- a/Zend/tests/try_finally_009.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Try finally (with for continue) ---FILE-- -<?php -function foo () { - for($i = 0; $i < 5; $i++) { - do { - try { - try { - } finally { - } - } catch (Exception $e) { - } finally { - continue; - } - } while (0); - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_009.php on line %d diff --git a/Zend/tests/try_finally_010.phpt b/Zend/tests/try_finally_010.phpt deleted file mode 100644 index 91eb782..0000000 --- a/Zend/tests/try_finally_010.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Try finally (function call in the finally block after exception) ---FILE-- -<?php -function foo() { - echo "4"; -} -function bar() { - try { - echo "2"; - throw new Exception(); - echo "x"; - } catch (MyEx $ex) { - echo "x"; - } finally { - echo "3"; - foo(); - echo "5"; - } -} -try { - echo "1"; - bar(); - echo "x"; -} catch (Exception $ex) { - echo "6"; -} -echo "\n"; ---EXPECT-- -123456 diff --git a/Zend/tests/try_finally_011.phpt b/Zend/tests/try_finally_011.phpt deleted file mode 100644 index 8a9dc62..0000000 --- a/Zend/tests/try_finally_011.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Try finally (segfault with empty break) ---FILE-- -<?php -function foo () { - try { - break; - } finally { - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: 'break' not in the 'loop' or 'switch' context in %stry_finally_011.php on line %d diff --git a/Zend/tests/try_finally_012.phpt b/Zend/tests/try_finally_012.phpt deleted file mode 100644 index 32fec7a..0000000 --- a/Zend/tests/try_finally_012.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Try finally (exception in "return" statement) ---FILE-- -<?php -class A { - public $x = 1; - public $y = 2; - function __destruct() { - throw new Exception(); - } -} -function foo() { - foreach(new A() as $a) { - try { - return $a; - } catch (Exception $e) { - echo "exception in foo\n"; - } finally { - echo "finally\n"; - } - } -} -try { - foo(); -} catch (Exception $e) { - echo "exception in main\n"; -} -?> ---EXPECT-- -finally -exception in main -
diff --git a/Zend/tests/catch_002.phpt b/Zend/tests/catch_002.phpt deleted file mode 100644 index 11d736a..0000000 --- a/Zend/tests/catch_002.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Catching an exception in a constructor ---FILE-- -<?php - -class MyObject -{ - function __construct() - { - throw new Exception(); - echo __METHOD__ . "() Must not be reached\n"; - } - - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } -} - -try -{ - new MyObject(); -} -catch(Exception $e) -{ - echo "Caught\n"; -} - -?> -===DONE=== ---EXPECT-- -Caught -===DONE=== diff --git a/Zend/tests/catch_003.phpt b/Zend/tests/catch_003.phpt deleted file mode 100644 index 414d50f..0000000 --- a/Zend/tests/catch_003.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Catching an exception in a constructor fired form a static method ---FILE-- -<?php - -class MyObject -{ - function fail() - { - throw new Exception(); - } - - function __construct() - { - self::fail(); - echo __METHOD__ . "() Must not be reached\n"; - } - - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } -} - -try -{ - new MyObject(); -} -catch(Exception $e) -{ - echo "Caught\n"; -} - -?> -===DONE=== ---EXPECT-- -Caught -===DONE=== diff --git a/Zend/tests/catch_004.phpt b/Zend/tests/catch_004.phpt deleted file mode 100644 index 54920b8..0000000 --- a/Zend/tests/catch_004.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Catching an exception in a constructor inside a static method ---FILE-- -<?php - -class MyObject -{ - function fail() - { - throw new Exception(); - } - - function __construct() - { - self::fail(); - echo __METHOD__ . "() Must not be reached\n"; - } - - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } - - static function test() - { - try - { - new MyObject(); - } - catch(Exception $e) - { - echo "Caught\n"; - } - } -} - -MyObject::test(); - -?> -===DONE=== ---EXPECT-- -Caught -===DONE=== diff --git a/Zend/tests/catch_finally_001.phpt b/Zend/tests/catch_finally_001.phpt deleted file mode 100644 index 0c3f597..0000000 --- a/Zend/tests/catch_finally_001.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Try catch finally (basic test) ---FILE-- -<?php -function foo ($throw = FALSE) { - try { - echo "try\n"; - if ($throw) { - throw new Exception("ex"); - } - } catch (Exception $e) { - echo "catch\n"; - } finally { - echo "finally\n"; - } - - echo "end\n"; -} - -foo(); -echo "\n"; -foo(true); -?> ---EXPECTF-- -try -finally -end - -try -catch -finally -end diff --git a/Zend/tests/catch_finally_002.phpt b/Zend/tests/catch_finally_002.phpt deleted file mode 100644 index c54477f..0000000 --- a/Zend/tests/catch_finally_002.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Try catch finally (basic test with return) ---FILE-- -<?php -function foo () { - try { - echo "try\n"; - return 1; - } catch (Exception $e) { - } finally { - echo "finally\n"; - } - return 2; -} - -var_dump(foo()); -?> ---EXPECTF-- -try -finally -int(1) diff --git a/Zend/tests/catch_finally_003.phpt b/Zend/tests/catch_finally_003.phpt deleted file mode 100644 index 24e468d..0000000 --- a/Zend/tests/catch_finally_003.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Try catch finally (with multi-returns) ---FILE-- -<?php -function dummy($msg) { - var_dump($msg); -} - -function foo ($a) { - try { - dummy("try"); - return $a; - } catch (Exception $e) { - throw $e; - } finally { - dummy("finally"); - return "finally"; - } - return "end"; -} - -function &bar($a) { - try { - echo "try\n"; - throw new Exception("ex"); - } catch (Exception $e) { - } finally { - return $a; - } - return ($c = "end"); -} -var_dump(foo("para")); -var_dump(bar("para")); -?> ---EXPECTF-- -string(3) "try" -string(7) "finally" -string(7) "finally" -try -string(4) "para" diff --git a/Zend/tests/catch_finally_004.phpt b/Zend/tests/catch_finally_004.phpt deleted file mode 100644 index a2c22be..0000000 --- a/Zend/tests/catch_finally_004.phpt +++ /dev/null @@ -1,41 +0,0 @@ ---TEST-- -Try catch finally (nesting try-catch-finally) ---FILE-- -<?php - -function throw_exception($msg) { - throw new Exception($msg); -} - -function foo (&$ex) { - try { - echo "1"; - try { - echo "2"; - throw_exception("try"); - } catch (Exception $e) { - echo "3"; - throw_exception("catch"); - } finally { - echo "4"; - throw_exception("finally"); - } - } catch (Exception $e) { - $ex = $e; - echo "3"; - } finally { - echo "2"; - } - return 1; -} - -var_dump(foo($ex)); - -do { - var_dump($ex->getMessage()); -} while ($ex = $ex->getPrevious()); -?> ---EXPECT-- -123432int(1) -string(7) "finally" -string(5) "catch" diff --git a/Zend/tests/catch_finally_005.phpt b/Zend/tests/catch_finally_005.phpt deleted file mode 100644 index c2fd55d..0000000 --- a/Zend/tests/catch_finally_005.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Try catch finally (with multi-returns and exception) ---FILE-- -<?php -function foo ($a) { - try { - throw new Exception("ex"); - } catch (PdoException $e) { - die("error"); - } catch (Exception $e) { - return 2; - } finally { - return 3; - } - return 1; -} - -var_dump(foo("para")); -?> ---EXPECTF-- -int(3) diff --git a/Zend/tests/catch_finally_006.phpt b/Zend/tests/catch_finally_006.phpt deleted file mode 100644 index 216219b..0000000 --- a/Zend/tests/catch_finally_006.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Try catch finally (re-throw exception in catch block) ---FILE-- -<?php -function foo ($a) { - try { - throw new Exception("ex"); - } catch (Exception $e) { - var_dump($a); - throw $e; - } finally { - var_dump("finally"); - return "return"; - } - return 1; -} - -try { - var_dump(foo("para")); -} catch (Exception $e) { - "caught exception" . PHP_EOL; - var_dump($e->getMessage()); -} -?> ---EXPECT-- -string(4) "para" -string(7) "finally" -string(6) "return" diff --git a/Zend/tests/finally_goto_001.phpt b/Zend/tests/finally_goto_001.phpt deleted file mode 100644 index 990f78d..0000000 --- a/Zend/tests/finally_goto_001.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -jmp into a finally block 01 ---FILE-- -<?php -function foo() { - goto test; - try { - } finally { -test: - } -} -?> ---EXPECTF-- -Fatal error: jump into a finally block is disallowed in %sfinally_goto_001.php on line %d diff --git a/Zend/tests/finally_goto_002.phpt b/Zend/tests/finally_goto_002.phpt deleted file mode 100644 index a6bd9e3..0000000 --- a/Zend/tests/finally_goto_002.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -jmp into a finally block 02 ---FILE-- -<?php -function foo() { - try { - goto test; - } finally { -test: - } -} -?> ---EXPECTF-- -Fatal error: jump into a finally block is disallowed in %sfinally_goto_002.php on line %d diff --git a/Zend/tests/finally_goto_003.phpt b/Zend/tests/finally_goto_003.phpt deleted file mode 100644 index 8529ff7..0000000 --- a/Zend/tests/finally_goto_003.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -jmp into a finally block 03 ---FILE-- -<?php -function foo() { - try { - } finally { - goto test; -test: - } -} -echo "okey"; -?> ---EXPECTF-- -okey diff --git a/Zend/tests/finally_goto_004.phpt b/Zend/tests/finally_goto_004.phpt deleted file mode 100644 index d88ceed..0000000 --- a/Zend/tests/finally_goto_004.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -jmp into a finally block 03 ---FILE-- -<?php -function foo() { - try { - } finally { -test: - } - goto test; -} -?> ---EXPECTF-- -Fatal error: jump into a finally block is disallowed in %sfinally_goto_004.php on line %d diff --git a/Zend/tests/try/catch_002.phpt b/Zend/tests/try/catch_002.phpt new file mode 100644 index 0000000..11d736a --- /dev/null +++ b/Zend/tests/try/catch_002.phpt @@ -0,0 +1,33 @@ +--TEST-- +Catching an exception in a constructor +--FILE-- +<?php + +class MyObject +{ + function __construct() + { + throw new Exception(); + echo __METHOD__ . "() Must not be reached\n"; + } + + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } +} + +try +{ + new MyObject(); +} +catch(Exception $e) +{ + echo "Caught\n"; +} + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/try/catch_003.phpt b/Zend/tests/try/catch_003.phpt new file mode 100644 index 0000000..414d50f --- /dev/null +++ b/Zend/tests/try/catch_003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Catching an exception in a constructor fired form a static method +--FILE-- +<?php + +class MyObject +{ + function fail() + { + throw new Exception(); + } + + function __construct() + { + self::fail(); + echo __METHOD__ . "() Must not be reached\n"; + } + + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } +} + +try +{ + new MyObject(); +} +catch(Exception $e) +{ + echo "Caught\n"; +} + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/try/catch_004.phpt b/Zend/tests/try/catch_004.phpt new file mode 100644 index 0000000..54920b8 --- /dev/null +++ b/Zend/tests/try/catch_004.phpt @@ -0,0 +1,43 @@ +--TEST-- +Catching an exception in a constructor inside a static method +--FILE-- +<?php + +class MyObject +{ + function fail() + { + throw new Exception(); + } + + function __construct() + { + self::fail(); + echo __METHOD__ . "() Must not be reached\n"; + } + + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } + + static function test() + { + try + { + new MyObject(); + } + catch(Exception $e) + { + echo "Caught\n"; + } + } +} + +MyObject::test(); + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/try/catch_finally_001.phpt b/Zend/tests/try/catch_finally_001.phpt new file mode 100644 index 0000000..0c3f597 --- /dev/null +++ b/Zend/tests/try/catch_finally_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +Try catch finally (basic test) +--FILE-- +<?php +function foo ($throw = FALSE) { + try { + echo "try\n"; + if ($throw) { + throw new Exception("ex"); + } + } catch (Exception $e) { + echo "catch\n"; + } finally { + echo "finally\n"; + } + + echo "end\n"; +} + +foo(); +echo "\n"; +foo(true); +?> +--EXPECTF-- +try +finally +end + +try +catch +finally +end diff --git a/Zend/tests/try/catch_finally_002.phpt b/Zend/tests/try/catch_finally_002.phpt new file mode 100644 index 0000000..c54477f --- /dev/null +++ b/Zend/tests/try/catch_finally_002.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try catch finally (basic test with return) +--FILE-- +<?php +function foo () { + try { + echo "try\n"; + return 1; + } catch (Exception $e) { + } finally { + echo "finally\n"; + } + return 2; +} + +var_dump(foo()); +?> +--EXPECTF-- +try +finally +int(1) diff --git a/Zend/tests/try/catch_finally_003.phpt b/Zend/tests/try/catch_finally_003.phpt new file mode 100644 index 0000000..24e468d --- /dev/null +++ b/Zend/tests/try/catch_finally_003.phpt @@ -0,0 +1,40 @@ +--TEST-- +Try catch finally (with multi-returns) +--FILE-- +<?php +function dummy($msg) { + var_dump($msg); +} + +function foo ($a) { + try { + dummy("try"); + return $a; + } catch (Exception $e) { + throw $e; + } finally { + dummy("finally"); + return "finally"; + } + return "end"; +} + +function &bar($a) { + try { + echo "try\n"; + throw new Exception("ex"); + } catch (Exception $e) { + } finally { + return $a; + } + return ($c = "end"); +} +var_dump(foo("para")); +var_dump(bar("para")); +?> +--EXPECTF-- +string(3) "try" +string(7) "finally" +string(7) "finally" +try +string(4) "para" diff --git a/Zend/tests/try/catch_finally_004.phpt b/Zend/tests/try/catch_finally_004.phpt new file mode 100644 index 0000000..a2c22be --- /dev/null +++ b/Zend/tests/try/catch_finally_004.phpt @@ -0,0 +1,41 @@ +--TEST-- +Try catch finally (nesting try-catch-finally) +--FILE-- +<?php + +function throw_exception($msg) { + throw new Exception($msg); +} + +function foo (&$ex) { + try { + echo "1"; + try { + echo "2"; + throw_exception("try"); + } catch (Exception $e) { + echo "3"; + throw_exception("catch"); + } finally { + echo "4"; + throw_exception("finally"); + } + } catch (Exception $e) { + $ex = $e; + echo "3"; + } finally { + echo "2"; + } + return 1; +} + +var_dump(foo($ex)); + +do { + var_dump($ex->getMessage()); +} while ($ex = $ex->getPrevious()); +?> +--EXPECT-- +123432int(1) +string(7) "finally" +string(5) "catch" diff --git a/Zend/tests/try/catch_finally_005.phpt b/Zend/tests/try/catch_finally_005.phpt new file mode 100644 index 0000000..c2fd55d --- /dev/null +++ b/Zend/tests/try/catch_finally_005.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try catch finally (with multi-returns and exception) +--FILE-- +<?php +function foo ($a) { + try { + throw new Exception("ex"); + } catch (PdoException $e) { + die("error"); + } catch (Exception $e) { + return 2; + } finally { + return 3; + } + return 1; +} + +var_dump(foo("para")); +?> +--EXPECTF-- +int(3) diff --git a/Zend/tests/try/catch_finally_006.phpt b/Zend/tests/try/catch_finally_006.phpt new file mode 100644 index 0000000..216219b --- /dev/null +++ b/Zend/tests/try/catch_finally_006.phpt @@ -0,0 +1,28 @@ +--TEST-- +Try catch finally (re-throw exception in catch block) +--FILE-- +<?php +function foo ($a) { + try { + throw new Exception("ex"); + } catch (Exception $e) { + var_dump($a); + throw $e; + } finally { + var_dump("finally"); + return "return"; + } + return 1; +} + +try { + var_dump(foo("para")); +} catch (Exception $e) { + "caught exception" . PHP_EOL; + var_dump($e->getMessage()); +} +?> +--EXPECT-- +string(4) "para" +string(7) "finally" +string(6) "return" diff --git a/Zend/tests/try/finally_goto_001.phpt b/Zend/tests/try/finally_goto_001.phpt new file mode 100644 index 0000000..990f78d --- /dev/null +++ b/Zend/tests/try/finally_goto_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +jmp into a finally block 01 +--FILE-- +<?php +function foo() { + goto test; + try { + } finally { +test: + } +} +?> +--EXPECTF-- +Fatal error: jump into a finally block is disallowed in %sfinally_goto_001.php on line %d diff --git a/Zend/tests/try/finally_goto_002.phpt b/Zend/tests/try/finally_goto_002.phpt new file mode 100644 index 0000000..a6bd9e3 --- /dev/null +++ b/Zend/tests/try/finally_goto_002.phpt @@ -0,0 +1,14 @@ +--TEST-- +jmp into a finally block 02 +--FILE-- +<?php +function foo() { + try { + goto test; + } finally { +test: + } +} +?> +--EXPECTF-- +Fatal error: jump into a finally block is disallowed in %sfinally_goto_002.php on line %d diff --git a/Zend/tests/try/finally_goto_003.phpt b/Zend/tests/try/finally_goto_003.phpt new file mode 100644 index 0000000..8529ff7 --- /dev/null +++ b/Zend/tests/try/finally_goto_003.phpt @@ -0,0 +1,15 @@ +--TEST-- +jmp into a finally block 03 +--FILE-- +<?php +function foo() { + try { + } finally { + goto test; +test: + } +} +echo "okey"; +?> +--EXPECTF-- +okey diff --git a/Zend/tests/try/finally_goto_004.phpt b/Zend/tests/try/finally_goto_004.phpt new file mode 100644 index 0000000..d88ceed --- /dev/null +++ b/Zend/tests/try/finally_goto_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +jmp into a finally block 03 +--FILE-- +<?php +function foo() { + try { + } finally { +test: + } + goto test; +} +?> +--EXPECTF-- +Fatal error: jump into a finally block is disallowed in %sfinally_goto_004.php on line %d diff --git a/Zend/tests/try/try_catch_finally_001.phpt b/Zend/tests/try/try_catch_finally_001.phpt new file mode 100644 index 0000000..3d478f4 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_001.phpt @@ -0,0 +1,36 @@ +--TEST-- +Try catch finally +--FILE-- +<?php + +class AE extends Exception {}; +class BE extends Exception {}; + +function foo () { + try { + try { + try { + throw new Exception("try"); + } catch (AE $e) { + echo "0"; + die("error"); + } finally { + echo "1"; + } + } finally { + echo "2"; + } + } catch (BE $e) { + die("error"); + } catch (Exception $e) { + echo "3"; + } finally { + echo "4"; + } + return 1; +} + +var_dump(foo()); +?> +--EXPECTF-- +1234int(1) diff --git a/Zend/tests/try/try_catch_finally_002.phpt b/Zend/tests/try/try_catch_finally_002.phpt new file mode 100644 index 0000000..79efcb3 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_002.phpt @@ -0,0 +1,42 @@ +--TEST-- +Try catch finally catch(multi catch blocks) +--FILE-- +<?php + +class AE extends Exception {}; +class BE extends Exception {}; + +function foo () { + try { + try { + try { + try { + echo "1"; + throw new Exception("try"); + } catch (AE $e) { + die("error"); + } finally { + echo "2"; + } + } finally { + echo "3"; + } + } catch (BE $e) { + die("error"); + } finally { + echo "4"; + } + } catch (Exception $e) { + echo "5"; + } catch (AE $e) { + die("error"); + } finally { + echo "6"; + } + return 7; +} + +var_dump(foo()); +?> +--EXPECTF-- +123456int(7) diff --git a/Zend/tests/try/try_catch_finally_003.phpt b/Zend/tests/try/try_catch_finally_003.phpt new file mode 100644 index 0000000..7ec8ec8 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_003.phpt @@ -0,0 +1,36 @@ +--TEST-- +Try catch finally (multi catch blocks with return) +--FILE-- +<?php + +class AE extends Exception {}; +class BE extends Exception {}; + +function foo () { + try { + try { + try { + throw new Exception("try"); + } catch (AE $e) { + die("error"); + } finally { + echo "1"; + } + } finally { + echo "2"; + } + } catch (BE $e) { + die("error"); + } catch (Exception $e) { + echo "3"; + } finally { + echo "4"; + return 4; + } + return 5; +} + +var_dump(foo()); +?> +--EXPECTF-- +1234int(4) diff --git a/Zend/tests/try/try_catch_finally_004.phpt b/Zend/tests/try/try_catch_finally_004.phpt new file mode 100644 index 0000000..eb8d096 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_004.phpt @@ -0,0 +1,30 @@ +--TEST-- +Try catch finally (re-throw exception in catch block) +--CREDITS-- +adoy +--FILE-- +<?php +function dummy($msg) { + var_dump($msg); +} +try { + try { + var_dump("try"); + return; + } catch (Exception $e) { + dummy("catch"); + throw $e; + } finally { + dummy("finally"); + } +} catch (Exception $e) { + dummy("catch2"); +} finally { + dummy("finally2"); +} +var_dump("end"); +?> +--EXPECTF-- +string(3) "try" +string(7) "finally" +string(8) "finally2" diff --git a/Zend/tests/try/try_catch_finally_005.phpt b/Zend/tests/try/try_catch_finally_005.phpt new file mode 100644 index 0000000..dafeb6b --- /dev/null +++ b/Zend/tests/try/try_catch_finally_005.phpt @@ -0,0 +1,52 @@ +--TEST-- +Try catch finally (break / cont in try block) +--CREDITS-- +adoy +--FILE-- +<?php +for ($i = 0; $i < 100 ; $i ++) { + try { + break; + } finally { + var_dump("break"); + } +} + + +for ($i = 0; $i < 2; $i ++) { + try { + continue; + } finally { + var_dump("continue1"); + } +} + +for ($i = 0; $i < 3; $i ++) { + try { + try { + continue; + } finally { + var_dump("continue2"); + if ($i == 1) { + throw new Exception("continue exception"); + } + } + } catch (Exception $e) { + var_dump("cactched"); + } finally { + var_dump("finally"); + } +} + +?> +--EXPECTF-- +string(5) "break" +string(9) "continue1" +string(9) "continue1" +string(9) "continue2" +string(7) "finally" +string(9) "continue2" +string(8) "cactched" +string(7) "finally" +string(9) "continue2" +string(7) "finally" diff --git a/Zend/tests/try/try_catch_finally_006.phpt b/Zend/tests/try/try_catch_finally_006.phpt new file mode 100644 index 0000000..dab6af6 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_006.phpt @@ -0,0 +1,39 @@ +--TEST-- +Try catch finally (goto in try/catch block) +--CREDITS-- +adoy +--FILE-- +<?php +function foo($ex = NULL) { + try { + try { + goto label; + } finally { + var_dump("finally1"); + if ($ex) throw $ex; + } + } catch (Exception $e) { + var_dump("catched"); + if ($ex) return "return1"; + } finally { + var_dump("finally2"); + } + +label: + var_dump("label"); + return "return2"; +} + +var_dump(foo()); +var_dump(foo(new Exception())); + +?> +--EXPECTF-- +string(8) "finally1" +string(8) "finally2" +string(5) "label" +string(7) "return2" +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(7) "return1" diff --git a/Zend/tests/try/try_catch_finally_007.phpt b/Zend/tests/try/try_catch_finally_007.phpt new file mode 100644 index 0000000..ad33c68 --- /dev/null +++ b/Zend/tests/try/try_catch_finally_007.phpt @@ -0,0 +1,46 @@ +--TEST-- +Try catch finally (goto in try/catch block) +--CREDITS-- +adoy +--FILE-- +<?php +function foo($ret = FALSE) { + try { + try { + do { + goto label; + } while(0); + foreach (array() as $val) { + continue; + } + } finally { + var_dump("finally1"); + throw new Exception("exception"); + } + } catch (Exception $e) { + goto local; +local: + var_dump("catched"); + if ($ret) return "return"; + } finally { + var_dump("finally2"); + } + +label: + var_dump("label"); +} + +var_dump(foo()); +var_dump(foo(true)); + +?> +--EXPECTF-- +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(5) "label" +NULL +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(6) "return" diff --git a/Zend/tests/try/try_finally_001.phpt b/Zend/tests/try/try_finally_001.phpt new file mode 100644 index 0000000..33744d0 --- /dev/null +++ b/Zend/tests/try/try_finally_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +Try finally (basic test) +--FILE-- +<?php +function foo ($a) { + try { + throw new Exception("ex"); + } finally { + var_dump($a); + } +} + +foo("finally"); +?> +--EXPECTF-- +string(7) "finally" + +Fatal error: Uncaught Exception: ex %s +Stack trace: +#0 %stry_finally_001.php(%d): foo('finally') +#1 {main} + thrown in %stry_finally_001.php on line %d diff --git a/Zend/tests/try/try_finally_002.phpt b/Zend/tests/try/try_finally_002.phpt new file mode 100644 index 0000000..99a34f6 --- /dev/null +++ b/Zend/tests/try/try_finally_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +Try finally (re-throw exception in finally block) +--FILE-- +<?php +function foo () { + try { + throw new Exception("try"); + } finally { + throw new Exception("finally"); + } +} + +try { + foo(); +} catch (Exception $e) { + do { + var_dump($e->getMessage()); + } while ($e = $e->getPrevious()); +} +?> +--EXPECT-- +string(7) "finally" +string(3) "try" diff --git a/Zend/tests/try/try_finally_003.phpt b/Zend/tests/try/try_finally_003.phpt new file mode 100644 index 0000000..b0fee7c --- /dev/null +++ b/Zend/tests/try/try_finally_003.phpt @@ -0,0 +1,27 @@ +--TEST-- +Try finally (call sequence test) +--FILE-- +<?php +function foo () { + try { + echo "1"; + try { + echo "2"; + throw new Exception("ex"); + } finally { + echo "3"; + } + } finally { + echo "4"; + } +} + +foo(); +?> +--EXPECTF-- +1234 +Fatal error: Uncaught Exception: ex %s +Stack trace: +#0 %stry_finally_003.php(%d): foo() +#1 {main} + thrown in %stry_finally_003.php on line %d diff --git a/Zend/tests/try/try_finally_004.phpt b/Zend/tests/try/try_finally_004.phpt new file mode 100644 index 0000000..08930a4 --- /dev/null +++ b/Zend/tests/try/try_finally_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +Try finally (without catch/finally block) +--FILE-- +<?php +function foo () { + try { + echo "3"; + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: Cannot use try without catch or finally in %stry_finally_004.php on line %d diff --git a/Zend/tests/try/try_finally_005.phpt b/Zend/tests/try/try_finally_005.phpt new file mode 100644 index 0000000..8664d6b --- /dev/null +++ b/Zend/tests/try/try_finally_005.phpt @@ -0,0 +1,17 @@ +--TEST-- +Try finally (with long goto) +--FILE-- +<?php +function foo () { + try { + } finally { + goto label; + } +label: + return 1; +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_005.php on line %d diff --git a/Zend/tests/try/try_finally_006.phpt b/Zend/tests/try/try_finally_006.phpt new file mode 100644 index 0000000..f53e6b5 --- /dev/null +++ b/Zend/tests/try/try_finally_006.phpt @@ -0,0 +1,26 @@ +--TEST-- +Try finally (with near goto) +--FILE-- +<?php +function foo () { + $jmp = 1; + try { + } finally { +previous: + if ($jmp) { + goto label; + echo "dummy"; +label: + echo "label\n"; + $jmp = 0; + goto previous; + } + echo "okey"; + } +} + +foo(); +?> +--EXPECTF-- +label +okey diff --git a/Zend/tests/try/try_finally_007.phpt b/Zend/tests/try/try_finally_007.phpt new file mode 100644 index 0000000..6349374 --- /dev/null +++ b/Zend/tests/try/try_finally_007.phpt @@ -0,0 +1,22 @@ +--TEST-- +Try finally (with goto previous label) +--FILE-- +<?php +function foo () { + try { +label: + echo "label"; + try { + } finally { + goto label; + echo "dummy"; + } + } catch (Exception $e) { + } finally { + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_007.php on line %d diff --git a/Zend/tests/try/try_finally_008.phpt b/Zend/tests/try/try_finally_008.phpt new file mode 100644 index 0000000..cee37ae --- /dev/null +++ b/Zend/tests/try/try_finally_008.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try finally (with break in do...while) +--FILE-- +<?php +function foo () { + do { + try { + try { + } finally { + break; + } + } catch (Exception $e) { + } finally { + } + } while (0); +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_008.php on line %d diff --git a/Zend/tests/try/try_finally_009.phpt b/Zend/tests/try/try_finally_009.phpt new file mode 100644 index 0000000..b29930a --- /dev/null +++ b/Zend/tests/try/try_finally_009.phpt @@ -0,0 +1,23 @@ +--TEST-- +Try finally (with for continue) +--FILE-- +<?php +function foo () { + for($i = 0; $i < 5; $i++) { + do { + try { + try { + } finally { + } + } catch (Exception $e) { + } finally { + continue; + } + } while (0); + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_009.php on line %d diff --git a/Zend/tests/try/try_finally_010.phpt b/Zend/tests/try/try_finally_010.phpt new file mode 100644 index 0000000..91eb782 --- /dev/null +++ b/Zend/tests/try/try_finally_010.phpt @@ -0,0 +1,30 @@ +--TEST-- +Try finally (function call in the finally block after exception) +--FILE-- +<?php +function foo() { + echo "4"; +} +function bar() { + try { + echo "2"; + throw new Exception(); + echo "x"; + } catch (MyEx $ex) { + echo "x"; + } finally { + echo "3"; + foo(); + echo "5"; + } +} +try { + echo "1"; + bar(); + echo "x"; +} catch (Exception $ex) { + echo "6"; +} +echo "\n"; +--EXPECT-- +123456 diff --git a/Zend/tests/try/try_finally_011.phpt b/Zend/tests/try/try_finally_011.phpt new file mode 100644 index 0000000..8a9dc62 --- /dev/null +++ b/Zend/tests/try/try_finally_011.phpt @@ -0,0 +1,15 @@ +--TEST-- +Try finally (segfault with empty break) +--FILE-- +<?php +function foo () { + try { + break; + } finally { + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: 'break' not in the 'loop' or 'switch' context in %stry_finally_011.php on line %d diff --git a/Zend/tests/try/try_finally_012.phpt b/Zend/tests/try/try_finally_012.phpt new file mode 100644 index 0000000..32fec7a --- /dev/null +++ b/Zend/tests/try/try_finally_012.phpt @@ -0,0 +1,32 @@ +--TEST-- +Try finally (exception in "return" statement) +--FILE-- +<?php +class A { + public $x = 1; + public $y = 2; + function __destruct() { + throw new Exception(); + } +} +function foo() { + foreach(new A() as $a) { + try { + return $a; + } catch (Exception $e) { + echo "exception in foo\n"; + } finally { + echo "finally\n"; + } + } +} +try { + foo(); +} catch (Exception $e) { + echo "exception in main\n"; +} +?> +--EXPECT-- +finally +exception in main + diff --git a/Zend/tests/try_catch_finally_001.phpt b/Zend/tests/try_catch_finally_001.phpt deleted file mode 100644 index 3d478f4..0000000 --- a/Zend/tests/try_catch_finally_001.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Try catch finally ---FILE-- -<?php - -class AE extends Exception {}; -class BE extends Exception {}; - -function foo () { - try { - try { - try { - throw new Exception("try"); - } catch (AE $e) { - echo "0"; - die("error"); - } finally { - echo "1"; - } - } finally { - echo "2"; - } - } catch (BE $e) { - die("error"); - } catch (Exception $e) { - echo "3"; - } finally { - echo "4"; - } - return 1; -} - -var_dump(foo()); -?> ---EXPECTF-- -1234int(1) diff --git a/Zend/tests/try_catch_finally_002.phpt b/Zend/tests/try_catch_finally_002.phpt deleted file mode 100644 index 79efcb3..0000000 --- a/Zend/tests/try_catch_finally_002.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Try catch finally catch(multi catch blocks) ---FILE-- -<?php - -class AE extends Exception {}; -class BE extends Exception {}; - -function foo () { - try { - try { - try { - try { - echo "1"; - throw new Exception("try"); - } catch (AE $e) { - die("error"); - } finally { - echo "2"; - } - } finally { - echo "3"; - } - } catch (BE $e) { - die("error"); - } finally { - echo "4"; - } - } catch (Exception $e) { - echo "5"; - } catch (AE $e) { - die("error"); - } finally { - echo "6"; - } - return 7; -} - -var_dump(foo()); -?> ---EXPECTF-- -123456int(7) diff --git a/Zend/tests/try_catch_finally_003.phpt b/Zend/tests/try_catch_finally_003.phpt deleted file mode 100644 index 7ec8ec8..0000000 --- a/Zend/tests/try_catch_finally_003.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Try catch finally (multi catch blocks with return) ---FILE-- -<?php - -class AE extends Exception {}; -class BE extends Exception {}; - -function foo () { - try { - try { - try { - throw new Exception("try"); - } catch (AE $e) { - die("error"); - } finally { - echo "1"; - } - } finally { - echo "2"; - } - } catch (BE $e) { - die("error"); - } catch (Exception $e) { - echo "3"; - } finally { - echo "4"; - return 4; - } - return 5; -} - -var_dump(foo()); -?> ---EXPECTF-- -1234int(4) diff --git a/Zend/tests/try_catch_finally_004.phpt b/Zend/tests/try_catch_finally_004.phpt deleted file mode 100644 index eb8d096..0000000 --- a/Zend/tests/try_catch_finally_004.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Try catch finally (re-throw exception in catch block) ---CREDITS-- -adoy ---FILE-- -<?php -function dummy($msg) { - var_dump($msg); -} -try { - try { - var_dump("try"); - return; - } catch (Exception $e) { - dummy("catch"); - throw $e; - } finally { - dummy("finally"); - } -} catch (Exception $e) { - dummy("catch2"); -} finally { - dummy("finally2"); -} -var_dump("end"); -?> ---EXPECTF-- -string(3) "try" -string(7) "finally" -string(8) "finally2" diff --git a/Zend/tests/try_catch_finally_005.phpt b/Zend/tests/try_catch_finally_005.phpt deleted file mode 100644 index dafeb6b..0000000 --- a/Zend/tests/try_catch_finally_005.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -Try catch finally (break / cont in try block) ---CREDITS-- -adoy ---FILE-- -<?php -for ($i = 0; $i < 100 ; $i ++) { - try { - break; - } finally { - var_dump("break"); - } -} - - -for ($i = 0; $i < 2; $i ++) { - try { - continue; - } finally { - var_dump("continue1"); - } -} - -for ($i = 0; $i < 3; $i ++) { - try { - try { - continue; - } finally { - var_dump("continue2"); - if ($i == 1) { - throw new Exception("continue exception"); - } - } - } catch (Exception $e) { - var_dump("cactched"); - } finally { - var_dump("finally"); - } -} - -?> ---EXPECTF-- -string(5) "break" -string(9) "continue1" -string(9) "continue1" -string(9) "continue2" -string(7) "finally" -string(9) "continue2" -string(8) "cactched" -string(7) "finally" -string(9) "continue2" -string(7) "finally" diff --git a/Zend/tests/try_catch_finally_006.phpt b/Zend/tests/try_catch_finally_006.phpt deleted file mode 100644 index dab6af6..0000000 --- a/Zend/tests/try_catch_finally_006.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Try catch finally (goto in try/catch block) ---CREDITS-- -adoy ---FILE-- -<?php -function foo($ex = NULL) { - try { - try { - goto label; - } finally { - var_dump("finally1"); - if ($ex) throw $ex; - } - } catch (Exception $e) { - var_dump("catched"); - if ($ex) return "return1"; - } finally { - var_dump("finally2"); - } - -label: - var_dump("label"); - return "return2"; -} - -var_dump(foo()); -var_dump(foo(new Exception())); - -?> ---EXPECTF-- -string(8) "finally1" -string(8) "finally2" -string(5) "label" -string(7) "return2" -string(8) "finally1" -string(7) "catched" -string(8) "finally2" -string(7) "return1" diff --git a/Zend/tests/try_catch_finally_007.phpt b/Zend/tests/try_catch_finally_007.phpt deleted file mode 100644 index ad33c68..0000000 --- a/Zend/tests/try_catch_finally_007.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Try catch finally (goto in try/catch block) ---CREDITS-- -adoy ---FILE-- -<?php -function foo($ret = FALSE) { - try { - try { - do { - goto label; - } while(0); - foreach (array() as $val) { - continue; - } - } finally { - var_dump("finally1"); - throw new Exception("exception"); - } - } catch (Exception $e) { - goto local; -local: - var_dump("catched"); - if ($ret) return "return"; - } finally { - var_dump("finally2"); - } - -label: - var_dump("label"); -} - -var_dump(foo()); -var_dump(foo(true)); - -?> ---EXPECTF-- -string(8) "finally1" -string(7) "catched" -string(8) "finally2" -string(5) "label" -NULL -string(8) "finally1" -string(7) "catched" -string(8) "finally2" -string(6) "return" diff --git a/Zend/tests/try_finally_001.phpt b/Zend/tests/try_finally_001.phpt deleted file mode 100644 index 33744d0..0000000 --- a/Zend/tests/try_finally_001.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Try finally (basic test) ---FILE-- -<?php -function foo ($a) { - try { - throw new Exception("ex"); - } finally { - var_dump($a); - } -} - -foo("finally"); -?> ---EXPECTF-- -string(7) "finally" - -Fatal error: Uncaught Exception: ex %s -Stack trace: -#0 %stry_finally_001.php(%d): foo('finally') -#1 {main} - thrown in %stry_finally_001.php on line %d diff --git a/Zend/tests/try_finally_002.phpt b/Zend/tests/try_finally_002.phpt deleted file mode 100644 index 99a34f6..0000000 --- a/Zend/tests/try_finally_002.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Try finally (re-throw exception in finally block) ---FILE-- -<?php -function foo () { - try { - throw new Exception("try"); - } finally { - throw new Exception("finally"); - } -} - -try { - foo(); -} catch (Exception $e) { - do { - var_dump($e->getMessage()); - } while ($e = $e->getPrevious()); -} -?> ---EXPECT-- -string(7) "finally" -string(3) "try" diff --git a/Zend/tests/try_finally_003.phpt b/Zend/tests/try_finally_003.phpt deleted file mode 100644 index b0fee7c..0000000 --- a/Zend/tests/try_finally_003.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Try finally (call sequence test) ---FILE-- -<?php -function foo () { - try { - echo "1"; - try { - echo "2"; - throw new Exception("ex"); - } finally { - echo "3"; - } - } finally { - echo "4"; - } -} - -foo(); -?> ---EXPECTF-- -1234 -Fatal error: Uncaught Exception: ex %s -Stack trace: -#0 %stry_finally_003.php(%d): foo() -#1 {main} - thrown in %stry_finally_003.php on line %d diff --git a/Zend/tests/try_finally_004.phpt b/Zend/tests/try_finally_004.phpt deleted file mode 100644 index 08930a4..0000000 --- a/Zend/tests/try_finally_004.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Try finally (without catch/finally block) ---FILE-- -<?php -function foo () { - try { - echo "3"; - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: Cannot use try without catch or finally in %stry_finally_004.php on line %d diff --git a/Zend/tests/try_finally_005.phpt b/Zend/tests/try_finally_005.phpt deleted file mode 100644 index 8664d6b..0000000 --- a/Zend/tests/try_finally_005.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Try finally (with long goto) ---FILE-- -<?php -function foo () { - try { - } finally { - goto label; - } -label: - return 1; -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_005.php on line %d diff --git a/Zend/tests/try_finally_006.phpt b/Zend/tests/try_finally_006.phpt deleted file mode 100644 index f53e6b5..0000000 --- a/Zend/tests/try_finally_006.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Try finally (with near goto) ---FILE-- -<?php -function foo () { - $jmp = 1; - try { - } finally { -previous: - if ($jmp) { - goto label; - echo "dummy"; -label: - echo "label\n"; - $jmp = 0; - goto previous; - } - echo "okey"; - } -} - -foo(); -?> ---EXPECTF-- -label -okey diff --git a/Zend/tests/try_finally_007.phpt b/Zend/tests/try_finally_007.phpt deleted file mode 100644 index 6349374..0000000 --- a/Zend/tests/try_finally_007.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Try finally (with goto previous label) ---FILE-- -<?php -function foo () { - try { -label: - echo "label"; - try { - } finally { - goto label; - echo "dummy"; - } - } catch (Exception $e) { - } finally { - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_007.php on line %d diff --git a/Zend/tests/try_finally_008.phpt b/Zend/tests/try_finally_008.phpt deleted file mode 100644 index cee37ae..0000000 --- a/Zend/tests/try_finally_008.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Try finally (with break in do...while) ---FILE-- -<?php -function foo () { - do { - try { - try { - } finally { - break; - } - } catch (Exception $e) { - } finally { - } - } while (0); -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_008.php on line %d diff --git a/Zend/tests/try_finally_009.phpt b/Zend/tests/try_finally_009.phpt deleted file mode 100644 index b29930a..0000000 --- a/Zend/tests/try_finally_009.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Try finally (with for continue) ---FILE-- -<?php -function foo () { - for($i = 0; $i < 5; $i++) { - do { - try { - try { - } finally { - } - } catch (Exception $e) { - } finally { - continue; - } - } while (0); - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: jump out of a finally block is disallowed in %stry_finally_009.php on line %d diff --git a/Zend/tests/try_finally_010.phpt b/Zend/tests/try_finally_010.phpt deleted file mode 100644 index 91eb782..0000000 --- a/Zend/tests/try_finally_010.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Try finally (function call in the finally block after exception) ---FILE-- -<?php -function foo() { - echo "4"; -} -function bar() { - try { - echo "2"; - throw new Exception(); - echo "x"; - } catch (MyEx $ex) { - echo "x"; - } finally { - echo "3"; - foo(); - echo "5"; - } -} -try { - echo "1"; - bar(); - echo "x"; -} catch (Exception $ex) { - echo "6"; -} -echo "\n"; ---EXPECT-- -123456 diff --git a/Zend/tests/try_finally_011.phpt b/Zend/tests/try_finally_011.phpt deleted file mode 100644 index 8a9dc62..0000000 --- a/Zend/tests/try_finally_011.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Try finally (segfault with empty break) ---FILE-- -<?php -function foo () { - try { - break; - } finally { - } -} - -foo(); -?> ---EXPECTF-- -Fatal error: 'break' not in the 'loop' or 'switch' context in %stry_finally_011.php on line %d diff --git a/Zend/tests/try_finally_012.phpt b/Zend/tests/try_finally_012.phpt deleted file mode 100644 index 32fec7a..0000000 --- a/Zend/tests/try_finally_012.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Try finally (exception in "return" statement) ---FILE-- -<?php -class A { - public $x = 1; - public $y = 2; - function __destruct() { - throw new Exception(); - } -} -function foo() { - foreach(new A() as $a) { - try { - return $a; - } catch (Exception $e) { - echo "exception in foo\n"; - } finally { - echo "finally\n"; - } - } -} -try { - foo(); -} catch (Exception $e) { - echo "exception in main\n"; -} -?> ---EXPECT-- -finally -exception in main -