cvs: ZendEngine2 /tests bug26166.phpt

From: Date: Thu, 06 Oct 2005 18:52:53 +0000
Subject: cvs: ZendEngine2 /tests bug26166.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4204@lists.php.net to get a copy of this message
helly Thu Oct 6 14:52:53 2005 EDT Modified files: /ZendEngine2/tests bug26166.phpt Log: - Fix test - Convert to unicode http://cvs.php.net/diff.php/ZendEngine2/tests/bug26166.phpt?r1=1.3&r2=1.4&ty=u Index: ZendEngine2/tests/bug26166.phpt diff -u ZendEngine2/tests/bug26166.phpt:1.3 ZendEngine2/tests/bug26166.phpt:1.4 --- ZendEngine2/tests/bug26166.phpt:1.3 Tue Sep 27 03:59:01 2005 +++ ZendEngine2/tests/bug26166.phpt Thu Oct 6 14:52:51 2005 @@ -1,67 +1,74 @@ ---TEST-- -Bug #26166 (__toString() crash when no values returned) ---FILE-- -<?php -class Foo -{ - function __toString() - { - return "Hello World!\n"; - } -} - -class Bar -{ - private $obj; - - function __construct() - { - $this->obj = new Foo(); - } - - function __toString() - { - return $this->obj->__toString(); - } -} - -$o = new Bar; -echo $o; - -echo "===THROW===\n"; - -class Error -{ - function __toString() { - throw new Exception("This is an error!"); - } -} - -$o = new Error; -try { - echo $o; -} -catch (Exception $e) { - echo "Got the exception\n"; -} - -echo "===NONE===\n"; - -class None -{ - function __toString() { - } -} - -$o = new None; -echo $o; - -?> -===DONE=== ---EXPECTF-- -Hello World! -===THROW=== -Got the exception -===NONE=== - -Catchable fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d +--TEST-- +Bug #26166 (__toString() crash when no values returned) +--FILE-- +<?php + +class Foo +{ + function __toString() + { + return "Hello World!\n"; + } +} + +class Bar +{ + private $obj; + + function __construct() + { + $this->obj = new Foo(); + } + + function __toString() + { + return $this->obj->__toString(); + } +} + +$o = new Bar; +echo $o; + +echo "===NONE===\n"; + +function my_error_handler($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} + +set_error_handler('my_error_handler'); + +class None +{ + function __toString() { + } +} + +$o = new None; +echo $o; + +echo "===THROW===\n"; + +class Error +{ + function __toString() { + throw new Exception("This is an error!"); + } +} + +$o = new Error; +try { + echo $o; +} +catch (Exception $e) { + echo "Got the exception\n"; +} + +?> +===DONE=== +--EXPECTF-- +Hello World! +===NONE=== +string(52) "Method None::__toString() must return a string value" +===THROW=== + +Fatal error: Object of class Error could not be converted to string in %sbug26166.php on line %d

« previous php.zend-engine.cvs (#4204) next »