kraghuba Fri Oct 19 18:34:16 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/array array_fill_error.phpt array_fill_variation1.phpt array_fill_variation2.phpt array_fill_object.phpt array_fill_variation3.phpt array_fill_basic.phpt array_fill_variation4.phpt array_fill_variation5.phpt Log: New testcases for array_fill() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_error.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_error.phpt +++ php-src/ext/standard/tests/array/array_fill_error.phpt --TEST-- Test array_fill() function : error conditions --FILE-- <?php /* Prototype : proto array array_fill(int start_key, int num, mixed val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */
echo "*** Testing array_fill() : error conditions ***\n"; // Zero arguments echo "-- Testing array_fill() function with Zero arguments --\n"; var_dump( array_fill() ); // More than expected number of arguments echo "-- Testing array_fill() function with more than expected no. of arguments --\n"; $start_key = 0; $num = 2; $val = 1; $extra_arg = 10; var_dump( array_fill($start_key,$num,$val, $extra_arg) ); // Less than the expected number of arguments echo "-- Testing array_fill() function with less than expected no. of arguments --\n"; $start_key = 0; $num = 2; var_dump( array_fill($start_key,$num) ); //calling array_fill with negative values for 'num' parameter $num = -1; var_dump( array_fill($start_key,$num,$val) ); //callin array_fill with 'num' equal to zero value $num = 0; var_dump( array_fill($start_key,$num,$val) ); echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : error conditions *** -- Testing array_fill() function with Zero arguments -- Warning: array_fill() expects exactly 3 parameters, 0 given in %s on line %d NULL -- Testing array_fill() function with more than expected no. of arguments -- Warning: array_fill() expects exactly 3 parameters, 4 given in %s on line %d NULL -- Testing array_fill() function with less than expected no. of arguments -- Warning: array_fill() expects exactly 3 parameters, 2 given in %s on line %d NULL Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) Done --UEXPECTF-- *** Testing array_fill() : error conditions *** -- Testing array_fill() function with Zero arguments -- Warning: array_fill() expects exactly 3 parameters, 0 given in %s on line %d NULL -- Testing array_fill() function with more than expected no. of arguments -- Warning: array_fill() expects exactly 3 parameters, 4 given in %s on line %d NULL -- Testing array_fill() function with less than expected no. of arguments -- Warning: array_fill() expects exactly 3 parameters, 2 given in %s on line %d NULL Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_variation1.phpt +++ php-src/ext/standard/tests/array/array_fill_variation1.phpt --TEST-- Test array_fill() function : usage variations - unexpected values for 'start_key' argument(Bug#43017) --FILE-- <?php /* Prototype : proto array array_fill(int start_key, int num, mixed val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ /* * testing array_fill() by passing different unexpected value for 'start_key' argument */ echo "*** Testing array_fill() : usage variations ***\n"; // Initialise function arguments not being substituted $num = 2; $val = 100; //get an unset variable $unset_var = 10; unset ($unset_var); //get a resource variable $fp = fopen(__FILE__, "r"); //define a class class test { var $t = 10; function __toString() { return "testObject"; } } //array of different values for 'start_key' argument $values = array( // float values /* 1 */ 10.5, -10.5, 12.3456789000e10, 12.34567890006E-10, .5, // array values /* 6 */ array(), array(0), array(1), array(1, 2), array('color' => 'red', 'item' => 'pen'), // null values /* 11 */ NULL, null, // boolean values /* 13 */ true, false, TRUE, FALSE, // empty string /* 17 */ "", '', // string values /* 19 */ "string", 'string', // objects /* 21 */ new test(), // undefined variable @$undefined_var, // unset variable @$unset_var, // resource variable /* 24 */ $fp ); // loop through each element of the array for start_key // check the working of array_fill() echo "--- Testing array_fill() with different values for 'start_key' arg ---\n"; $counter = 1; for($index = 0; $index < count($values); $index ++) { echo "-- Iteration $counter --\n"; $start_key = $values[$index]; var_dump( array_fill($start_key,$num,$val) ); $counter ++; } // close the resource used fclose($fp); echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different values for 'start_key' arg --- -- Iteration 1 -- array(2) { [10]=> int(100) [11]=> int(100) } -- Iteration 2 -- array(2) { [-10]=> int(100) [0]=> int(100) } -- Iteration 3 -- array(2) { [-1097262584]=> int(100) [0]=> int(100) } -- Iteration 4 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 5 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 6 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 7 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 8 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 9 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 10 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 11 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 12 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 13 -- array(2) { [1]=> int(100) [2]=> int(100) } -- Iteration 14 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 15 -- array(2) { [1]=> int(100) [2]=> int(100) } -- Iteration 16 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 17 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 18 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 19 -- Warning: array_fill() expects parameter 1 to be long, string given in %s on line %d NULL -- Iteration 20 -- Warning: array_fill() expects parameter 1 to be long, string given in %s on line %d NULL -- Iteration 21 -- Warning: array_fill() expects parameter 1 to be long, object given in %s on line %d NULL -- Iteration 22 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 23 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 24 -- Warning: array_fill() expects parameter 1 to be long, resource given in %s on line %d NULL Done --UEXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different values for 'start_key' arg --- -- Iteration 1 -- array(2) { [10]=> int(100) [11]=> int(100) } -- Iteration 2 -- array(2) { [-10]=> int(100) [0]=> int(100) } -- Iteration 3 -- array(2) { [-1097262584]=> int(100) [0]=> int(100) } -- Iteration 4 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 5 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 6 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 7 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 8 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 9 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 10 -- Warning: array_fill() expects parameter 1 to be long, array given in %s on line %d NULL -- Iteration 11 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 12 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 13 -- array(2) { [1]=> int(100) [2]=> int(100) } -- Iteration 14 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 15 -- array(2) { [1]=> int(100) [2]=> int(100) } -- Iteration 16 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 17 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 18 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 19 -- Warning: array_fill() expects parameter 1 to be long, Unicode string given in %s on line %d NULL -- Iteration 20 -- Warning: array_fill() expects parameter 1 to be long, Unicode string given in %s on line %d NULL -- Iteration 21 -- Warning: array_fill() expects parameter 1 to be long, object given in %s on line %d NULL -- Iteration 22 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 23 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 24 -- Warning: array_fill() expects parameter 1 to be long, resource given in %s on line %d NULL Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_variation2.phpt +++ php-src/ext/standard/tests/array/array_fill_variation2.phpt --TEST-- Test array_fill() function : usage variations - unexpected values for 'num' argument --FILE-- <?php /* Prototype : proto array array_fill(int start_key, int num, mixed val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ /* * testing array_fill() by passing different unexpected values for 'num' argument */ echo "*** Testing array_fill() : usage variations ***\n"; // Initialise function arguments not being substituted $start_key = 0; $val = 100; //get an unset variable $unset_var = 10; unset ($unset_var); //define a class class test { var $t = 10; function __toString() { return "testObject"; } } //array of different values for 'num' argument $values = array( // float values /* 1 */ 2.5, -2.5, 0.5e1, 0.5E-1, .5, // array values /* 6 */ array(), array(0), array(1), array(1, 2), array('color' => 'red', 'item' => 'pen'), // null values /* 11 */ NULL, null, // boolean values /* 13 */ true, false, TRUE, FALSE, // empty string /* 17 */ "", '', // string values /* 19 */ "string", 'string', // objects /* 21 */ new test(), // undefined variable @$undefined_var, // unset variable /* 24 */ @$unset_var, ); // loop through each element of the array for num // check the working of array_fill echo "--- Testing array_fill() with different values for 'num' arg ---\n"; $counter = 1; for($index = 0; $index < count($values); $index ++) { echo "-- Iteration $counter --\n"; $num = $values[$index]; var_dump( array_fill($start_key,$num,$val) ); $counter ++; } echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different values for 'num' arg --- -- Iteration 1 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 2 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 3 -- array(5) { [0]=> int(100) [1]=> int(100) [2]=> int(100) [3]=> int(100) [4]=> int(100) } -- Iteration 4 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 5 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 6 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 7 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 8 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 9 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 10 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 11 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 12 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 13 -- array(1) { [0]=> int(100) } -- Iteration 14 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 15 -- array(1) { [0]=> int(100) } -- Iteration 16 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 17 -- Warning: array_fill() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 18 -- Warning: array_fill() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 19 -- Warning: array_fill() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 20 -- Warning: array_fill() expects parameter 2 to be long, string given in %s on line %d NULL -- Iteration 21 -- Warning: array_fill() expects parameter 2 to be long, object given in %s on line %d NULL -- Iteration 22 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 23 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) Done --UEXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different values for 'num' arg --- -- Iteration 1 -- array(2) { [0]=> int(100) [1]=> int(100) } -- Iteration 2 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 3 -- array(5) { [0]=> int(100) [1]=> int(100) [2]=> int(100) [3]=> int(100) [4]=> int(100) } -- Iteration 4 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 5 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 6 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 7 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 8 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 9 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 10 -- Warning: array_fill() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 11 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 12 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 13 -- array(1) { [0]=> int(100) } -- Iteration 14 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 15 -- array(1) { [0]=> int(100) } -- Iteration 16 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 17 -- Warning: array_fill() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 18 -- Warning: array_fill() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 19 -- Warning: array_fill() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 20 -- Warning: array_fill() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 21 -- Warning: array_fill() expects parameter 2 to be long, object given in %s on line %d NULL -- Iteration 22 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) -- Iteration 23 -- Warning: array_fill(): Number of elements must be positive in %s on line %d bool(false) Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_object.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_object.phpt +++ php-src/ext/standard/tests/array/array_fill_object.phpt --TEST-- Test array_fill() function : usage variations - various object values for 'val' argument --FILE-- <?php /* Prototype : array array_fill(int $start_key, int $num, mixed $val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ /* * testing array_fill() by passing various object values for 'val' argument */ echo "*** Testing array_fill() : usage variations ***\n"; // Initialise function arguments not being substituted $start_key = 0; $num = 2; // class without a member class Test { } //class with public member, static member , constant and consturctor to initialize the public member class Test1 { const test1_constant = "test1"; public static $test1_static = 0; public $member1; var $var1 = 30; var $var2; function __construct($value1 , $value2) { $this->member1 = $value1; $this->var2 = $value2; } } // child class which inherits parent class test1 class Child_test1 extends Test1 { public $member2; function __construct($value1 , $value2 , $value3) { parent::__construct($value1 , $value2); $this->member2 = $value3; } } //class with private member, static member, constant and constructor to initialize the private member class Test2 { const test2_constant = "test2"; public static $test2_static = 0; private $member1; var $var1 = 30; var $var2; function __construct($value1 , $value2) { $this->member1 = $value1; $this->var2 = $value2; } } // child class which inherits parent class test2 class Child_test2 extends Test2 { private $member1; function __construct($value1 , $value2 , $value3) { parent::__construct($value1 , $value2); $this->member1 = $value3; } } // class with protected member, static member, constant and consturctor to initialize the protected member class Test3 { const test3_constant = "test3"; public static $test3_static = 0; protected $member1; var $var1 = 30; var $var2; function __construct($value1 , $value2) { $this->member1 = $value1; $this->var2 = $value2; } } // child class which inherits parent class test3 class Child_test3 extends Test3 { protected $member1; function __construct($value1 , $value2 , $value3) { parent::__construct($value1 , $value2); $this->member1 = $value3; } } // class with public, private, protected members, static, constant members and constructor to initialize all the members class Test4 { const test4_constant = "test4"; public static $test4_static = 0; public $member1; private $member2; protected $member3; function __construct($value1 , $value2 , $value3) { $this->member1 = $value1; $this->member2 = $value2; $this->member3 = $value3; } } // child class which inherits parent class test4 class Child_test4 extends Test4 { var $var1; function __construct($value1 , $value2 , $value3 , $value4) { parent::__construct($value1 , $value2 , $value3); $this->var1 = $value4; } } // abstract class with public, private, protected members abstract class AbstractClass { public $member1; private $member2; protected $member3; var $var1 = 30; abstract protected function display(); } // implement abstract 'AbstractClass' class class ConcreteClass1 extends AbstractClass { protected function display() { echo "class name is ConcreteClass1 \n"; } } // declarationn of the interface 'iTemplate' interface iTemplate { public function display(); } // implement the interface 'iTemplate' class Template1 implements iTemplate { public function display() { echo "class name is Template1\n"; } } //array of object values for 'val' argument $objects = array( /* 1 */ new Test(), new Test1(100 , 101), new Child_test1(100 , 101 , 102), new Test2(100 , 101), /* 5 */ new Child_test2(100 , 101 , 102), new Test3(100 , 101), new Child_test3(100 , 101 , 102), new Test4( 100 , 101 , 102), new Child_test4(100 , 101 , 102 , 103), new ConcreteClass1(), /* 11 */ new Template1() ); // loop through each element of the array for 'val' argument // check the working of array_fill() echo "--- Testing array_fill() with different object values for 'val' argument ---\n"; $counter = 1; for($index = 0; $index < count($objects); $index ++) { echo "-- Iteration $counter --\n"; $val = $objects[$index]; var_dump( array_fill($start_key,$num,$val) ); $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different object values for 'val' argument --- -- Iteration 1 -- array(2) { [0]=> object(Test)#%d (0) { } [1]=> object(Test)#%d (0) { } } -- Iteration 2 -- array(2) { [0]=> object(Test1)#%d (3) { ["member1"]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } [1]=> object(Test1)#%d (3) { ["member1"]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } } -- Iteration 3 -- array(2) { [0]=> object(Child_test1)#%d (4) { ["member2"]=> int(102) ["member1"]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } [1]=> object(Child_test1)#%d (4) { ["member2"]=> int(102) ["member1"]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } } -- Iteration 4 -- array(2) { [0]=> object(Test2)#%d (3) { ["member1":"Test2":private]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } [1]=> object(Test2)#%d (3) { ["member1":"Test2":private]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } } -- Iteration 5 -- array(2) { [0]=> object(Child_test2)#%d (4) { ["member1":"Child_test2":private]=> int(102) ["member1":"Test2":private]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } [1]=> object(Child_test2)#%d (4) { ["member1":"Child_test2":private]=> int(102) ["member1":"Test2":private]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } } -- Iteration 6 -- array(2) { [0]=> object(Test3)#%d (3) { ["member1":protected]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } [1]=> object(Test3)#%d (3) { ["member1":protected]=> int(100) ["var1"]=> int(30) ["var2"]=> int(101) } } -- Iteration 7 -- array(2) { [0]=> object(Child_test3)#%d (3) { ["member1":protected]=> int(102) ["var1"]=> int(30) ["var2"]=> int(101) } [1]=> object(Child_test3)#%d (3) { ["member1":protected]=> int(102) ["var1"]=> int(30) ["var2"]=> int(101) } } -- Iteration 8 -- array(2) { [0]=> object(Test4)#%d (3) { ["member1"]=> int(100) ["member2":"Test4":private]=> int(101) ["member3":protected]=> int(102) } [1]=> object(Test4)#%d (3) { ["member1"]=> int(100) ["member2":"Test4":private]=> int(101) ["member3":protected]=> int(102) } } -- Iteration 9 -- array(2) { [0]=> object(Child_test4)#%d (4) { ["var1"]=> int(103) ["member1"]=> int(100) ["member2":"Test4":private]=> int(101) ["member3":protected]=> int(102) } [1]=> object(Child_test4)#%d (4) { ["var1"]=> int(103) ["member1"]=> int(100) ["member2":"Test4":private]=> int(101) ["member3":protected]=> int(102) } } -- Iteration 10 -- array(2) { [0]=> object(ConcreteClass1)#%d (4) { ["member1"]=> NULL ["member2":"AbstractClass":private]=> NULL ["member3":protected]=> NULL ["var1"]=> int(30) } [1]=> object(ConcreteClass1)#%d (4) { ["member1"]=> NULL ["member2":"AbstractClass":private]=> NULL ["member3":protected]=> NULL ["var1"]=> int(30) } } -- Iteration 11 -- array(2) { [0]=> object(Template1)#%d (0) { } [1]=> object(Template1)#%d (0) { } } Done --UEXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different object values for 'val' argument --- -- Iteration 1 -- array(2) { [0]=> object(Test)#%d (0) { } [1]=> object(Test)#%d (0) { } } -- Iteration 2 -- array(2) { [0]=> object(Test1)#%d (3) { [u"member1"]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } [1]=> object(Test1)#%d (3) { [u"member1"]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } } -- Iteration 3 -- array(2) { [0]=> object(Child_test1)#%d (4) { [u"member2"]=> int(102) [u"member1"]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } [1]=> object(Child_test1)#%d (4) { [u"member2"]=> int(102) [u"member1"]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } } -- Iteration 4 -- array(2) { [0]=> object(Test2)#%d (3) { [u"member1":u"Test2":private]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } [1]=> object(Test2)#%d (3) { [u"member1":u"Test2":private]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } } -- Iteration 5 -- array(2) { [0]=> object(Child_test2)#%d (4) { [u"member1":u"Child_test2":private]=> int(102) [u"member1":u"Test2":private]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } [1]=> object(Child_test2)#%d (4) { [u"member1":u"Child_test2":private]=> int(102) [u"member1":u"Test2":private]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } } -- Iteration 6 -- array(2) { [0]=> object(Test3)#%d (3) { [u"member1":protected]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } [1]=> object(Test3)#%d (3) { [u"member1":protected]=> int(100) [u"var1"]=> int(30) [u"var2"]=> int(101) } } -- Iteration 7 -- array(2) { [0]=> object(Child_test3)#%d (3) { [u"member1":protected]=> int(102) [u"var1"]=> int(30) [u"var2"]=> int(101) } [1]=> object(Child_test3)#%d (3) { [u"member1":protected]=> int(102) [u"var1"]=> int(30) [u"var2"]=> int(101) } } -- Iteration 8 -- array(2) { [0]=> object(Test4)#%d (3) { [u"member1"]=> int(100) [u"member2":u"Test4":private]=> int(101) [u"member3":protected]=> int(102) } [1]=> object(Test4)#%d (3) { [u"member1"]=> int(100) [u"member2":u"Test4":private]=> int(101) [u"member3":protected]=> int(102) } } -- Iteration 9 -- array(2) { [0]=> object(Child_test4)#%d (4) { [u"var1"]=> int(103) [u"member1"]=> int(100) [u"member2":u"Test4":private]=> int(101) [u"member3":protected]=> int(102) } [1]=> object(Child_test4)#%d (4) { [u"var1"]=> int(103) [u"member1"]=> int(100) [u"member2":u"Test4":private]=> int(101) [u"member3":protected]=> int(102) } } -- Iteration 10 -- array(2) { [0]=> object(ConcreteClass1)#%d (4) { [u"member1"]=> NULL [u"member2":u"AbstractClass":private]=> NULL [u"member3":protected]=> NULL [u"var1"]=> int(30) } [1]=> object(ConcreteClass1)#%d (4) { [u"member1"]=> NULL [u"member2":u"AbstractClass":private]=> NULL [u"member3":protected]=> NULL [u"var1"]=> int(30) } } -- Iteration 11 -- array(2) { [0]=> object(Template1)#%d (0) { } [1]=> object(Template1)#%d (0) { } } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_variation3.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_variation3.phpt +++ php-src/ext/standard/tests/array/array_fill_variation3.phpt --TEST-- Test array_fill() function : usage variations - unexpected values for 'val' argument --FILE-- <?php /* Prototype : array array_fill(int $start_key, int $num, mixed $val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ /* * testing array_fill() by passing different unexpected values for 'val' argument */ echo "*** Testing array_fill() : usage variations ***\n"; // Initialise function arguments not being substituted $start_key = 0; $num = 2; //get an unset variable $unset_var = 10; unset ($unset_var); // define a class class test { var $t = 10; function __toString() { return "testObject"; } } //array of different values for 'val' argument $values = array( // empty string /* 1 */ "", '', // objects /* 3 */ new test(), // undefined variable @$undefined_var, // unset variable /* 5 */ @$unset_var, ); // loop through each element of the array for 'val' argument // check the working of array_fill() echo "--- Testing array_fill() with different values for 'val' argument ---\n"; $counter = 1; for($index = 0; $index < count($values); $index ++) { echo "-- Iteration $counter --\n"; $val = $values[$index]; var_dump( array_fill($start_key , $num , $val) ); $counter++; } echo"Done"; ?> --EXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different values for 'val' argument --- -- Iteration 1 -- array(2) { [0]=> string(0) "" [1]=> string(0) "" } -- Iteration 2 -- array(2) { [0]=> string(0) "" [1]=> string(0) "" } -- Iteration 3 -- array(2) { [0]=> object(test)#%d (1) { ["t"]=> int(10) } [1]=> object(test)#%d (1) { ["t"]=> int(10) } } -- Iteration 4 -- array(2) { [0]=> NULL [1]=> NULL } -- Iteration 5 -- array(2) { [0]=> NULL [1]=> NULL } Done --UEXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different values for 'val' argument --- -- Iteration 1 -- array(2) { [0]=> unicode(0) "" [1]=> unicode(0) "" } -- Iteration 2 -- array(2) { [0]=> unicode(0) "" [1]=> unicode(0) "" } -- Iteration 3 -- array(2) { [0]=> object(test)#%d (1) { [u"t"]=> int(10) } [1]=> object(test)#%d (1) { [u"t"]=> int(10) } } -- Iteration 4 -- array(2) { [0]=> NULL [1]=> NULL } -- Iteration 5 -- array(2) { [0]=> NULL [1]=> NULL } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_basic.phpt +++ php-src/ext/standard/tests/array/array_fill_basic.phpt --TEST-- Test array_fill() function : basic functionality --FILE-- <?php /* Prototype : proto array array_fill(int start_key, int num, mixed val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ echo "*** Testing array_fill() : basic functionality ***\n"; // calling the array_fill with all possible valid values for 'val' argument $start_key = 0 ; $num = 2; $heredoc = <<<HERE_DOC Hello HERE_DOC; // array of possible valid values for 'val' arugment $values = array ( /* 1 */ NULL, 0, 1, /* 4 */ 1.5, 'hi', "hi", /* 7 */ $heredoc ); $counter = 1; for($i = 0; $i < count($values); $i ++) { echo "-- Iteration $counter --\n"; $val = $values[$i]; var_dump( array_fill($start_key,$num,$val) ); $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : basic functionality *** -- Iteration 1 -- array(2) { [0]=> NULL [1]=> NULL } -- Iteration 2 -- array(2) { [0]=> int(0) [1]=> int(0) } -- Iteration 3 -- array(2) { [0]=> int(1) [1]=> int(1) } -- Iteration 4 -- array(2) { [0]=> float(1.5) [1]=> float(1.5) } -- Iteration 5 -- array(2) { [0]=> string(2) "hi" [1]=> string(2) "hi" } -- Iteration 6 -- array(2) { [0]=> string(2) "hi" [1]=> string(2) "hi" } -- Iteration 7 -- array(2) { [0]=> string(5) "Hello" [1]=> string(5) "Hello" } Done --UEXPECTF-- *** Testing array_fill() : basic functionality *** -- Iteration 1 -- array(2) { [0]=> NULL [1]=> NULL } -- Iteration 2 -- array(2) { [0]=> int(0) [1]=> int(0) } -- Iteration 3 -- array(2) { [0]=> int(1) [1]=> int(1) } -- Iteration 4 -- array(2) { [0]=> float(1.5) [1]=> float(1.5) } -- Iteration 5 -- array(2) { [0]=> unicode(2) "hi" [1]=> unicode(2) "hi" } -- Iteration 6 -- array(2) { [0]=> unicode(2) "hi" [1]=> unicode(2) "hi" } -- Iteration 7 -- array(2) { [0]=> unicode(5) "Hello" [1]=> unicode(5) "Hello" } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_variation4.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_variation4.phpt +++ php-src/ext/standard/tests/array/array_fill_variation4.phpt --TEST-- Test array_fill() function : usage variations - using return value of array_fill for 'val' argument --FILE-- <?php /* Prototype : proto array array_fill(int start_key, int num, mixed val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ /* passing array_fill() as the 'val' argument in array_fill() function */ echo "*** Testing array_fill() : variation ***\n"; $start_key = 0; $num = 2; $heredoc = <<<HERE_DOC Hello HERE_DOC; // array of possible valid values for 'val' arugment $values = array ( /* 1 */ NULL, 0, 1, /* 4 */ 1.0, 'hi', "hi", /* 7 */ $heredoc ); echo "*** Filling 2 dimensional array with all basic valid values ***\n"; $counter = 1; for($i =0; $i < count($values); $i ++) { echo "-- Iteration $counter --\n"; $val = $values[$i]; var_dump( array_fill($start_key,$num,array_fill($start_key,$num,$val)) ); $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : variation *** *** Filling 2 dimensional array with all basic valid values *** -- Iteration 1 -- array(2) { [0]=> array(2) { [0]=> NULL [1]=> NULL } [1]=> array(2) { [0]=> NULL [1]=> NULL } } -- Iteration 2 -- array(2) { [0]=> array(2) { [0]=> int(0) [1]=> int(0) } [1]=> array(2) { [0]=> int(0) [1]=> int(0) } } -- Iteration 3 -- array(2) { [0]=> array(2) { [0]=> int(1) [1]=> int(1) } [1]=> array(2) { [0]=> int(1) [1]=> int(1) } } -- Iteration 4 -- array(2) { [0]=> array(2) { [0]=> float(1) [1]=> float(1) } [1]=> array(2) { [0]=> float(1) [1]=> float(1) } } -- Iteration 5 -- array(2) { [0]=> array(2) { [0]=> string(2) "hi" [1]=> string(2) "hi" } [1]=> array(2) { [0]=> string(2) "hi" [1]=> string(2) "hi" } } -- Iteration 6 -- array(2) { [0]=> array(2) { [0]=> string(2) "hi" [1]=> string(2) "hi" } [1]=> array(2) { [0]=> string(2) "hi" [1]=> string(2) "hi" } } -- Iteration 7 -- array(2) { [0]=> array(2) { [0]=> string(5) "Hello" [1]=> string(5) "Hello" } [1]=> array(2) { [0]=> string(5) "Hello" [1]=> string(5) "Hello" } } Done --UEXPECTF-- *** Testing array_fill() : variation *** *** Filling 2 dimensional array with all basic valid values *** -- Iteration 1 -- array(2) { [0]=> array(2) { [0]=> NULL [1]=> NULL } [1]=> array(2) { [0]=> NULL [1]=> NULL } } -- Iteration 2 -- array(2) { [0]=> array(2) { [0]=> int(0) [1]=> int(0) } [1]=> array(2) { [0]=> int(0) [1]=> int(0) } } -- Iteration 3 -- array(2) { [0]=> array(2) { [0]=> int(1) [1]=> int(1) } [1]=> array(2) { [0]=> int(1) [1]=> int(1) } } -- Iteration 4 -- array(2) { [0]=> array(2) { [0]=> float(1) [1]=> float(1) } [1]=> array(2) { [0]=> float(1) [1]=> float(1) } } -- Iteration 5 -- array(2) { [0]=> array(2) { [0]=> unicode(2) "hi" [1]=> unicode(2) "hi" } [1]=> array(2) { [0]=> unicode(2) "hi" [1]=> unicode(2) "hi" } } -- Iteration 6 -- array(2) { [0]=> array(2) { [0]=> unicode(2) "hi" [1]=> unicode(2) "hi" } [1]=> array(2) { [0]=> unicode(2) "hi" [1]=> unicode(2) "hi" } } -- Iteration 7 -- array(2) { [0]=> array(2) { [0]=> unicode(5) "Hello" [1]=> unicode(5) "Hello" } [1]=> array(2) { [0]=> unicode(5) "Hello" [1]=> unicode(5) "Hello" } } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_fill_variation5.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_fill_variation5.phpt +++ php-src/ext/standard/tests/array/array_fill_variation5.phpt --TEST-- Test array_fill() function : usage variations - different types of array values for 'val' argument --FILE-- <?php /* Prototype : array array_fill(int $start_key, int $num, mixed $val) * Description: Create an array containing num elements starting with index start_key each initialized to val * Source code: ext/standard/array.c */ /* * testing array_fill() by passing different types of array values for 'val' argument */ echo "*** Testing array_fill() : usage variations ***\n"; // Initialise function arguments not being substituted $start_key = 0; $num = 2; //array of different types of array values for 'val' argument $values = array( /* 1 */ array(), array(1 , 2 , 3 , 4), array(1 => "Hi" , 2 => "Hello"), array("Saffron" , "White" , "Green"), /* 5 */ array('color' => 'red' , 'item' => 'pen'), array( 'color' => 'red' , 2 => 'green ' ), array("colour" => "red" , "item" => "pen"), array( TRUE => "red" , FALSE => "green" ), array( true => "red" , FALSE => "green" ), /* 10 */ array( 1 => "Hi" , "color" => "red" , 'item' => 'pen'), array( NULL => "Hi", '1' => "Hello" , "1" => "Green"), array( ""=>1, "color" => "green"), /* 13 */ array('Saffron' , 'White' , 'Green') ); // loop through each element of the values array for 'val' argument // check the working of array_fill() echo "--- Testing array_fill() with different types of array values for 'val' argument ---\n"; $counter = 1; for($i = 0; $i < count($values); $i++) { echo "-- Iteration $counter --\n"; $val = $values[$i]; var_dump( array_fill($start_key , $num , $val) ); $counter++; } echo "Done"; ?> --EXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different types of array values for 'val' argument --- -- Iteration 1 -- array(2) { [0]=> array(0) { } [1]=> array(0) { } } -- Iteration 2 -- array(2) { [0]=> array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } [1]=> array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } } -- Iteration 3 -- array(2) { [0]=> array(2) { [1]=> string(2) "Hi" [2]=> string(5) "Hello" } [1]=> array(2) { [1]=> string(2) "Hi" [2]=> string(5) "Hello" } } -- Iteration 4 -- array(2) { [0]=> array(3) { [0]=> string(7) "Saffron" [1]=> string(5) "White" [2]=> string(5) "Green" } [1]=> array(3) { [0]=> string(7) "Saffron" [1]=> string(5) "White" [2]=> string(5) "Green" } } -- Iteration 5 -- array(2) { [0]=> array(2) { ["color"]=> string(3) "red" ["item"]=> string(3) "pen" } [1]=> array(2) { ["color"]=> string(3) "red" ["item"]=> string(3) "pen" } } -- Iteration 6 -- array(2) { [0]=> array(2) { ["color"]=> string(3) "red" [2]=> string(6) "green " } [1]=> array(2) { ["color"]=> string(3) "red" [2]=> string(6) "green " } } -- Iteration 7 -- array(2) { [0]=> array(2) { ["colour"]=> string(3) "red" ["item"]=> string(3) "pen" } [1]=> array(2) { ["colour"]=> string(3) "red" ["item"]=> string(3) "pen" } } -- Iteration 8 -- array(2) { [0]=> array(2) { [1]=> string(3) "red" [0]=> string(5) "green" } [1]=> array(2) { [1]=> string(3) "red" [0]=> string(5) "green" } } -- Iteration 9 -- array(2) { [0]=> array(2) { [1]=> string(3) "red" [0]=> string(5) "green" } [1]=> array(2) { [1]=> string(3) "red" [0]=> string(5) "green" } } -- Iteration 10 -- array(2) { [0]=> array(3) { [1]=> string(2) "Hi" ["color"]=> string(3) "red" ["item"]=> string(3) "pen" } [1]=> array(3) { [1]=> string(2) "Hi" ["color"]=> string(3) "red" ["item"]=> string(3) "pen" } } -- Iteration 11 -- array(2) { [0]=> array(2) { [""]=> string(2) "Hi" [1]=> string(5) "Green" } [1]=> array(2) { [""]=> string(2) "Hi" [1]=> string(5) "Green" } } -- Iteration 12 -- array(2) { [0]=> array(2) { [""]=> int(1) ["color"]=> string(5) "green" } [1]=> array(2) { [""]=> int(1) ["color"]=> string(5) "green" } } -- Iteration 13 -- array(2) { [0]=> array(3) { [0]=> string(7) "Saffron" [1]=> string(5) "White" [2]=> string(5) "Green" } [1]=> array(3) { [0]=> string(7) "Saffron" [1]=> string(5) "White" [2]=> string(5) "Green" } } Done --UEXPECTF-- *** Testing array_fill() : usage variations *** --- Testing array_fill() with different types of array values for 'val' argument --- -- Iteration 1 -- array(2) { [0]=> array(0) { } [1]=> array(0) { } } -- Iteration 2 -- array(2) { [0]=> array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } [1]=> array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } } -- Iteration 3 -- array(2) { [0]=> array(2) { [1]=> unicode(2) "Hi" [2]=> unicode(5) "Hello" } [1]=> array(2) { [1]=> unicode(2) "Hi" [2]=> unicode(5) "Hello" } } -- Iteration 4 -- array(2) { [0]=> array(3) { [0]=> unicode(7) "Saffron" [1]=> unicode(5) "White" [2]=> unicode(5) "Green" } [1]=> array(3) { [0]=> unicode(7) "Saffron" [1]=> unicode(5) "White" [2]=> unicode(5) "Green" } } -- Iteration 5 -- array(2) { [0]=> array(2) { [u"color"]=> unicode(3) "red" [u"item"]=> unicode(3) "pen" } [1]=> array(2) { [u"color"]=> unicode(3) "red" [u"item"]=> unicode(3) "pen" } } -- Iteration 6 -- array(2) { [0]=> array(2) { [u"color"]=> unicode(3) "red" [2]=> unicode(6) "green " } [1]=> array(2) { [u"color"]=> unicode(3) "red" [2]=> unicode(6) "green " } } -- Iteration 7 -- array(2) { [0]=> array(2) { [u"colour"]=> unicode(3) "red" [u"item"]=> unicode(3) "pen" } [1]=> array(2) { [u"colour"]=> unicode(3) "red" [u"item"]=> unicode(3) "pen" } } -- Iteration 8 -- array(2) { [0]=> array(2) { [1]=> unicode(3) "red" [0]=> unicode(5) "green" } [1]=> array(2) { [1]=> unicode(3) "red" [0]=> unicode(5) "green" } } -- Iteration 9 -- array(2) { [0]=> array(2) { [1]=> unicode(3) "red" [0]=> unicode(5) "green" } [1]=> array(2) { [1]=> unicode(3) "red" [0]=> unicode(5) "green" } } -- Iteration 10 -- array(2) { [0]=> array(3) { [1]=> unicode(2) "Hi" [u"color"]=> unicode(3) "red" [u"item"]=> unicode(3) "pen" } [1]=> array(3) { [1]=> unicode(2) "Hi" [u"color"]=> unicode(3) "red" [u"item"]=> unicode(3) "pen" } } -- Iteration 11 -- array(2) { [0]=> array(2) { [u""]=> unicode(2) "Hi" [1]=> unicode(5) "Green" } [1]=> array(2) { [u""]=> unicode(2) "Hi" [1]=> unicode(5) "Green" } } -- Iteration 12 -- array(2) { [0]=> array(2) { [u""]=> int(1) [u"color"]=> unicode(5) "green" } [1]=> array(2) { [u""]=> int(1) [u"color"]=> unicode(5) "green" } } -- Iteration 13 -- array(2) { [0]=> array(3) { [0]=> unicode(7) "Saffron" [1]=> unicode(5) "White" [2]=> unicode(5) "Green" } [1]=> array(3) { [0]=> unicode(7) "Saffron" [1]=> unicode(5) "White" [2]=> unicode(5) "Green" } } Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php