cvs: ZendEngine2(PHP_5_2) /tests cast_to_array.phpt cast_to_bool.phpt cast_to_double.phpt cast_to_int.phpt cast_to_object.phpt cast_to_string.phpt
settype_array.phpt settype_bool.phpt settype_double.phpt settype_int.phpt settype_null.phpt settype_object.phpt settype_resource.phpt
settype_string.phpt

From: Date: Fri, 27 Apr 2007 21:33:02 +0000
Subject: cvs: ZendEngine2(PHP_5_2) /tests cast_to_array.phpt cast_to_bool.phpt cast_to_double.phpt cast_to_int.phpt cast_to_object.phpt cast_to_string.phpt
settype_array.phpt settype_bool.phpt settype_double.phpt settype_int.phpt settype_null.phpt settype_object.phpt settype_resource.phpt
settype_string.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5755@lists.php.net to get a copy of this message
tony2001 Fri Apr 27 21:33:02 2007 UTC Added files: (Branch: PHP_5_2) /ZendEngine2/tests cast_to_array.phpt cast_to_bool.phpt cast_to_double.phpt cast_to_int.phpt cast_to_object.phpt cast_to_string.phpt settype_array.phpt settype_bool.phpt settype_double.phpt settype_int.phpt settype_null.phpt settype_object.phpt settype_resource.phpt settype_string.phpt Log: add new tests

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/cast_to_array.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/cast_to_array.phpt +++ ZendEngine2/tests/cast_to_array.phpt --TEST-- casting different variables to array --FILE-- <?php $r = fopen(__FILE__, "r"); class test { private $var1 = 1; public $var2 = 2; protected $var3 = 3; function __toString() { return "10"; } } $o = new test; $vars = array( "string", "", "\0", "8754456", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { $tmp = (array)$var; var_dump($tmp); } echo "Done\n"; ?> --EXPECTF-- array(1) { [0]=> string(6) "string" } array(1) { [0]=> string(0) "" } array(1) { [0]=> string(1) " } array(1) { [0]=> string(7) "8754456" } array(1) { [0]=> int(9876545) } array(1) { [0]=> float(0.1) } array(0) { } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(0) { } array(1) { [0]=> resource(%d) of type (stream) } array(3) { [" int(1) ["var2"]=> int(2) [" int(3) } Done --UEXPECTF-- array(1) { [0]=> unicode(6) "string" } array(1) { [0]=> unicode(0) "" } array(1) { [0]=> unicode(1) " } array(1) { [0]=> unicode(7) "8754456" } array(1) { [0]=> int(9876545) } array(1) { [0]=> float(0.1) } array(0) { } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(0) { } array(1) { [0]=> resource(%d) of type (stream) } array(3) { [u" int(1) [u"var2"]=> int(2) [u" int(3) } Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/cast_to_bool.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/cast_to_bool.phpt +++ ZendEngine2/tests/cast_to_bool.phpt --TEST-- casting different variables to boolean --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { $tmp = (bool)$var; var_dump($tmp); } echo "Done\n"; ?> --EXPECTF-- bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(true) Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/cast_to_double.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/cast_to_double.phpt +++ ZendEngine2/tests/cast_to_double.phpt --TEST-- casting different variables to double --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { $tmp = (double)$var; var_dump($tmp); } echo "Done\n"; ?> --EXPECTF-- float(0) float(8754456) float(0) float(0) float(9876545) float(0.1) float(0) float(1) float(0) float(1) float(0) float(%d) Notice: Object of class test could not be converted to double in %s on line %d float(1) Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/cast_to_int.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/cast_to_int.phpt +++ ZendEngine2/tests/cast_to_int.phpt --TEST-- casting different variables to integer --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { $tmp = (int)$var; var_dump($tmp); } echo "Done\n"; ?> --EXPECTF-- int(0) int(8754456) int(0) int(0) int(9876545) int(0) int(0) int(1) int(0) int(1) int(0) int(%d) Notice: Object of class test could not be converted to int in %s on line %d int(1) Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/cast_to_object.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/cast_to_object.phpt +++ ZendEngine2/tests/cast_to_object.phpt --TEST-- casting different variables to object --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { $tmp = (object)$var; var_dump($tmp); } echo "Done\n"; ?> --EXPECTF-- object(stdClass)#%d (1) { ["scalar"]=> string(6) "string" } object(stdClass)#%d (1) { ["scalar"]=> string(7) "8754456" } object(stdClass)#%d (1) { ["scalar"]=> string(0) "" } object(stdClass)#%d (1) { ["scalar"]=> string(1) " } object(stdClass)#%d (1) { ["scalar"]=> int(9876545) } object(stdClass)#%d (1) { ["scalar"]=> float(0.1) } object(stdClass)#%d (0) { } object(stdClass)#%d (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#%d (1) { ["scalar"]=> bool(false) } object(stdClass)#%d (1) { ["scalar"]=> bool(true) } object(stdClass)#%d (0) { } object(stdClass)#%d (1) { ["scalar"]=> resource(%d) of type (stream) } object(test)#%d (0) { } Done --UEXPECTF-- object(stdClass)#%d (1) { [u"scalar"]=> unicode(6) "string" } object(stdClass)#%d (1) { [u"scalar"]=> unicode(7) "8754456" } object(stdClass)#%d (1) { [u"scalar"]=> unicode(0) "" } object(stdClass)#%d (1) { [u"scalar"]=> unicode(1) " } object(stdClass)#%d (1) { [u"scalar"]=> int(9876545) } object(stdClass)#%d (1) { [u"scalar"]=> float(0.1) } object(stdClass)#%d (0) { } object(stdClass)#%d (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#%d (1) { [u"scalar"]=> bool(false) } object(stdClass)#%d (1) { [u"scalar"]=> bool(true) } object(stdClass)#%d (0) { } object(stdClass)#%d (1) { [u"scalar"]=> resource(%d) of type (stream) } object(test)#%d (0) { } Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/cast_to_string.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/cast_to_string.phpt +++ ZendEngine2/tests/cast_to_string.phpt --TEST-- casting different variables to string --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { $tmp = (string)$var; var_dump($tmp); } echo "Done\n"; ?> --EXPECTF-- string(6) "string" string(7) "8754456" string(0) "" string(1) " string(7) "9876545" string(3) "0.1" Notice: Array to string conversion in %s on line %d string(5) "Array" Notice: Array to string conversion in %s on line %d string(5) "Array" string(0) "" string(1) "1" string(0) "" string(%d) "Resource id #%d" string(2) "10" Done --UEXPECTF-- unicode(6) "string" unicode(7) "8754456" unicode(0) "" unicode(1) " unicode(7) "9876545" unicode(3) "0.1" unicode(5) "Array" unicode(5) "Array" unicode(0) "" unicode(1) "1" unicode(0) "" unicode(%d) "Resource id #%d" unicode(2) "10" Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_array.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_array.phpt +++ ZendEngine2/tests/settype_array.phpt --TEST-- casting different variables to array using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { private $var1 = 1; public $var2 = 2; protected $var3 = 3; function __toString() { return "10"; } } $o = new test; $vars = array( "string", "", "\0", "8754456", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "array"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- array(1) { [0]=> string(6) "string" } array(1) { [0]=> string(0) "" } array(1) { [0]=> string(1) " } array(1) { [0]=> string(7) "8754456" } array(1) { [0]=> int(9876545) } array(1) { [0]=> float(0.1) } array(0) { } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(0) { } array(1) { [0]=> resource(%d) of type (stream) } array(3) { [" int(1) ["var2"]=> int(2) [" int(3) } Done --UEXPECTF-- array(1) { [0]=> unicode(6) "string" } array(1) { [0]=> unicode(0) "" } array(1) { [0]=> unicode(1) " } array(1) { [0]=> unicode(7) "8754456" } array(1) { [0]=> int(9876545) } array(1) { [0]=> float(0.1) } array(0) { } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(1) { [0]=> bool(false) } array(1) { [0]=> bool(true) } array(0) { } array(1) { [0]=> resource(%d) of type (stream) } array(3) { [u" int(1) [u"var2"]=> int(2) [u" int(3) } Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_bool.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_bool.phpt +++ ZendEngine2/tests/settype_bool.phpt --TEST-- casting different variables to boolean using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "bool"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- bool(true) bool(true) bool(false) bool(true) bool(true) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(true) Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_double.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_double.phpt +++ ZendEngine2/tests/settype_double.phpt --TEST-- casting different variables to double using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "double"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- float(0) float(8754456) float(0) float(0) float(9876545) float(0.1) float(0) float(1) float(0) float(1) float(0) float(%d) Notice: Object of class test could not be converted to double in %s on line %d float(1) Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_int.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_int.phpt +++ ZendEngine2/tests/settype_int.phpt --TEST-- casting different variables to integer using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "int"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- int(0) int(8754456) int(0) int(0) int(9876545) int(0) int(0) int(1) int(0) int(1) int(0) int(%d) Notice: Object of class test could not be converted to int in %s on line %d int(1) Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_null.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_null.phpt +++ ZendEngine2/tests/settype_null.phpt --TEST-- casting different variables to null using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "null"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_object.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_object.phpt +++ ZendEngine2/tests/settype_object.phpt --TEST-- casting different variables to object using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "object"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- object(stdClass)#%d (1) { ["scalar"]=> string(6) "string" } object(stdClass)#%d (1) { ["scalar"]=> string(7) "8754456" } object(stdClass)#%d (1) { ["scalar"]=> string(0) "" } object(stdClass)#%d (1) { ["scalar"]=> string(1) " } object(stdClass)#%d (1) { ["scalar"]=> int(9876545) } object(stdClass)#%d (1) { ["scalar"]=> float(0.1) } object(stdClass)#%d (0) { } object(stdClass)#%d (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#%d (1) { ["scalar"]=> bool(false) } object(stdClass)#%d (1) { ["scalar"]=> bool(true) } object(stdClass)#%d (0) { } object(stdClass)#%d (1) { ["scalar"]=> resource(%d) of type (stream) } object(test)#%d (0) { } Done --UEXPECTF-- object(stdClass)#%d (1) { [u"scalar"]=> unicode(6) "string" } object(stdClass)#%d (1) { [u"scalar"]=> unicode(7) "8754456" } object(stdClass)#%d (1) { [u"scalar"]=> unicode(0) "" } object(stdClass)#%d (1) { [u"scalar"]=> unicode(1) " } object(stdClass)#%d (1) { [u"scalar"]=> int(9876545) } object(stdClass)#%d (1) { [u"scalar"]=> float(0.1) } object(stdClass)#%d (0) { } object(stdClass)#%d (3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } object(stdClass)#%d (1) { [u"scalar"]=> bool(false) } object(stdClass)#%d (1) { [u"scalar"]=> bool(true) } object(stdClass)#%d (0) { } object(stdClass)#%d (1) { [u"scalar"]=> resource(%d) of type (stream) } object(test)#%d (0) { } Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_resource.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_resource.phpt +++ ZendEngine2/tests/settype_resource.phpt --TEST-- casting different variables to resource using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "resource"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- Warning: settype(): Cannot convert to resource type in %s on line %d string(6) "string" Warning: settype(): Cannot convert to resource type in %s on line %d string(7) "8754456" Warning: settype(): Cannot convert to resource type in %s on line %d string(0) "" Warning: settype(): Cannot convert to resource type in %s on line %d string(1) " Warning: settype(): Cannot convert to resource type in %s on line %d int(9876545) Warning: settype(): Cannot convert to resource type in %s on line %d float(0.1) Warning: settype(): Cannot convert to resource type in %s on line %d array(0) { } Warning: settype(): Cannot convert to resource type in %s on line %d array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } Warning: settype(): Cannot convert to resource type in %s on line %d bool(false) Warning: settype(): Cannot convert to resource type in %s on line %d bool(true) Warning: settype(): Cannot convert to resource type in %s on line %d NULL Warning: settype(): Cannot convert to resource type in %s on line %d resource(%d) of type (stream) Warning: settype(): Cannot convert to resource type in %s on line %d object(test)#%d (0) { } Done --UEXPECTF-- Warning: settype(): Cannot convert to resource type in %s on line %d unicode(6) "string" Warning: settype(): Cannot convert to resource type in %s on line %d unicode(7) "8754456" Warning: settype(): Cannot convert to resource type in %s on line %d unicode(0) "" Warning: settype(): Cannot convert to resource type in %s on line %d unicode(1) " Warning: settype(): Cannot convert to resource type in %s on line %d int(9876545) Warning: settype(): Cannot convert to resource type in %s on line %d float(0.1) Warning: settype(): Cannot convert to resource type in %s on line %d array(0) { } Warning: settype(): Cannot convert to resource type in %s on line %d array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } Warning: settype(): Cannot convert to resource type in %s on line %d bool(false) Warning: settype(): Cannot convert to resource type in %s on line %d bool(true) Warning: settype(): Cannot convert to resource type in %s on line %d NULL Warning: settype(): Cannot convert to resource type in %s on line %d resource(%d) of type (stream) Warning: settype(): Cannot convert to resource type in %s on line %d object(test)#%d (0) { } Done http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/settype_string.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/settype_string.phpt +++ ZendEngine2/tests/settype_string.phpt --TEST-- casting different variables to string using settype() --FILE-- <?php $r = fopen(__FILE__, "r"); class test { function __toString() { return "10"; } } $o = new test; $vars = array( "string", "8754456", "", "\0", 9876545, 0.10, array(), array(1,2,3), false, true, NULL, $r, $o ); foreach ($vars as $var) { settype($var, "string"); var_dump($var); } echo "Done\n"; ?> --EXPECTF-- string(6) "string" string(7) "8754456" string(0) "" string(1) " string(7) "9876545" string(3) "0.1" Notice: Array to string conversion in %s on line %d string(5) "Array" Notice: Array to string conversion in %s on line %d string(5) "Array" string(0) "" string(1) "1" string(0) "" string(%d) "Resource id #%d" string(2) "10" Done --UEXPECTF-- unicode(6) "string" unicode(7) "8754456" unicode(0) "" unicode(1) " unicode(7) "9876545" unicode(3) "0.1" Notice: Array to string conversion in %s on line %d unicode(5) "Array" Notice: Array to string conversion in %s on line %d unicode(5) "Array" unicode(0) "" unicode(1) "1" unicode(0) "" unicode(%d) "Resource id #%d" unicode(2) "10" Done
« previous php.zend-engine.cvs (#5755) next »