]> granicus.if.org Git - php/commitdiff
- Add new test
authorMarcus Boerger <helly@php.net>
Sun, 25 Jul 2004 19:21:21 +0000 (19:21 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 25 Jul 2004 19:21:21 +0000 (19:21 +0000)
tests/classes/ctor_failure.phpt [new file with mode: 0755]

diff --git a/tests/classes/ctor_failure.phpt b/tests/classes/ctor_failure.phpt
new file mode 100755 (executable)
index 0000000..bbebca2
--- /dev/null
@@ -0,0 +1,33 @@
+--TEST--
+Do not call destructors if constructor fails
+--FILE--
+<?php
+
+class Test
+{
+    function __construct($msg) {
+        echo __METHOD__ . "($msg)\n";
+        throw new Exception($msg);
+    }
+    
+    function __destruct() {
+        echo __METHOD__ . "\n";
+    }
+}
+
+try
+{
+    $o = new Test('Hello');
+    unset($o);
+}
+catch (Exception $e)
+{
+    echo 'Caught ' . get_class($e) . '(' . $e->getMessage() . ")\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Test::__construct(Hello)
+Caught Exception(Hello)
+===DONE===