File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes / ctor_failure.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: ZE2 Do not call destructors if constructor fails
    3: --FILE--
    4: <?php
    5: 
    6: class Test
    7: {
    8:     function __construct($msg) {
    9:         echo __METHOD__ . "($msg)\n";
   10:         throw new Exception($msg);
   11:     }
   12:     
   13:     function __destruct() {
   14:         echo __METHOD__ . "\n";
   15:     }
   16: }
   17: 
   18: try
   19: {
   20:     $o = new Test('Hello');
   21:     unset($o);
   22: }
   23: catch (Exception $e)
   24: {
   25:     echo 'Caught ' . get_class($e) . '(' . $e->getMessage() . ")\n";
   26: }
   27: 
   28: ?>
   29: ===DONE===
   30: --EXPECT--
   31: Test::__construct(Hello)
   32: Caught Exception(Hello)
   33: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>