From b1c09efa90ce4b33d0d5d74cdf6c2e23e66039e9 Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Tue, 11 Dec 2007 10:50:17 +0000 Subject: [PATCH] New testcases for array_walk() function --- .../tests/array/array_walk_basic1.phpt | 80 ++++++ .../tests/array/array_walk_basic2.phpt | 105 +++++++ .../tests/array/array_walk_error1.phpt | 48 ++++ .../tests/array/array_walk_error2.phpt | 59 ++++ .../tests/array/array_walk_object1.phpt | Bin 0 -> 1391 bytes .../tests/array/array_walk_object2.phpt | 104 +++++++ .../array/array_walk_recursive_basic1.phpt | 80 ++++++ .../array/array_walk_recursive_basic2.phpt | 105 +++++++ .../array/array_walk_recursive_error1.phpt | 48 ++++ .../array/array_walk_recursive_error2.phpt | 59 ++++ .../array/array_walk_recursive_object1.phpt | Bin 0 -> 1441 bytes .../array/array_walk_recursive_object2.phpt | 106 +++++++ .../array_walk_recursive_variation1.phpt | 250 ++++++++++++++++ .../array_walk_recursive_variation2.phpt | 271 ++++++++++++++++++ .../array_walk_recursive_variation3.phpt | 123 ++++++++ .../array_walk_recursive_variation4.phpt | 76 +++++ .../array_walk_recursive_variation5.phpt | 64 +++++ .../array_walk_recursive_variation6.phpt | 147 ++++++++++ .../array_walk_recursive_variation7.phpt | 93 ++++++ .../array_walk_recursive_variation8.phpt | 42 +++ .../array_walk_recursive_variation9.phpt | 99 +++++++ .../tests/array/array_walk_variation1.phpt | 250 ++++++++++++++++ .../tests/array/array_walk_variation2.phpt | 271 ++++++++++++++++++ .../tests/array/array_walk_variation3.phpt | 123 ++++++++ .../tests/array/array_walk_variation4.phpt | 87 ++++++ .../tests/array/array_walk_variation5.phpt | 64 +++++ .../tests/array/array_walk_variation6.phpt | 143 +++++++++ .../tests/array/array_walk_variation7.phpt | 93 ++++++ .../tests/array/array_walk_variation8.phpt | 42 +++ .../tests/array/array_walk_variation9.phpt | 99 +++++++ 30 files changed, 3131 insertions(+) create mode 100644 ext/standard/tests/array/array_walk_basic1.phpt create mode 100644 ext/standard/tests/array/array_walk_basic2.phpt create mode 100644 ext/standard/tests/array/array_walk_error1.phpt create mode 100644 ext/standard/tests/array/array_walk_error2.phpt create mode 100644 ext/standard/tests/array/array_walk_object1.phpt create mode 100644 ext/standard/tests/array/array_walk_object2.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_basic1.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_basic2.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_error1.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_error2.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_object1.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_object2.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation1.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation2.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation3.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation4.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation5.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation6.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation7.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation8.phpt create mode 100644 ext/standard/tests/array/array_walk_recursive_variation9.phpt create mode 100644 ext/standard/tests/array/array_walk_variation1.phpt create mode 100644 ext/standard/tests/array/array_walk_variation2.phpt create mode 100644 ext/standard/tests/array/array_walk_variation3.phpt create mode 100644 ext/standard/tests/array/array_walk_variation4.phpt create mode 100644 ext/standard/tests/array/array_walk_variation5.phpt create mode 100644 ext/standard/tests/array/array_walk_variation6.phpt create mode 100644 ext/standard/tests/array/array_walk_variation7.phpt create mode 100644 ext/standard/tests/array/array_walk_variation8.phpt create mode 100644 ext/standard/tests/array/array_walk_variation9.phpt diff --git a/ext/standard/tests/array/array_walk_basic1.phpt b/ext/standard/tests/array/array_walk_basic1.phpt new file mode 100644 index 0000000000..34e8e88c73 --- /dev/null +++ b/ext/standard/tests/array/array_walk_basic1.phpt @@ -0,0 +1,80 @@ +--TEST-- +Test array_walk() function : basic functionality - regular array +--FILE-- + +--EXPECT-- +*** Testing array_walk() : basic functionality *** +-- Using array_walk() with default parameters to show array contents -- +string(5) "lemon" +int(0) + +string(6) "orange" +int(1) + +string(6) "banana" +int(2) + +string(5) "apple" +int(3) + +bool(true) +-- Using array_walk() with all parameters -- +string(5) "lemon" +int(0) +string(5) "Added" + +string(6) "orange" +int(1) +string(5) "Added" + +string(6) "banana" +int(2) +string(5) "Added" + +string(5) "apple" +int(3) +string(5) "Added" + +bool(true) +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_walk_basic2.phpt b/ext/standard/tests/array/array_walk_basic2.phpt new file mode 100644 index 0000000000..e856b580ba --- /dev/null +++ b/ext/standard/tests/array/array_walk_basic2.phpt @@ -0,0 +1,105 @@ +--TEST-- +Test array_walk() function : basic functionality - associative array +--FILE-- + "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); + +// User defined callback functions +/* Prototype : test_alter(mixed $item, mixed $key, string $prefix) + * Parameters : item - value in key/value pair + * key - key in key/value pair + * prefix - string to be added + * Description : alters the array values by appending prefix string + */ +function test_alter(&$item, $key, $prefix) +{ + // dump the arguments to check that they are passed + // with proper type + var_dump($item); // value + var_dump($key); // key + var_dump($prefix); // additional agument passed to callback function + echo "\n"; // new line to separate the output between each element +} + +/* Prototype : test_print(mixed $item, mixed $key) + * Parameters : item - value in key/value pair + * key - key in key/value pair + * Description : prints the array values with keys + */ +function test_print($item, $key) +{ + // dump the arguments to check that they are passed + // with proper type + var_dump($item); // value + var_dump($key); // key + echo "\n"; // new line to separate the output between each element +} + +echo "-- Using array_walk with default parameters to show array contents --\n"; +var_dump(array_walk($fruits, 'test_print')); + +echo "-- Using array_walk with one optional parameter to modify contents --\n"; +var_dump (array_walk($fruits, 'test_alter', 'fruit')); + +echo "-- Using array_walk with default parameters to show modified array contents --\n"; +var_dump (array_walk($fruits, 'test_print')); + +echo "Done"; +?> +--EXPECT-- +*** Testing array_walk() : basic functionality *** +-- Using array_walk with default parameters to show array contents -- +string(5) "lemon" +string(1) "d" + +string(6) "orange" +string(1) "a" + +string(6) "banana" +string(1) "b" + +string(5) "apple" +string(1) "c" + +bool(true) +-- Using array_walk with one optional parameter to modify contents -- +string(5) "lemon" +string(1) "d" +string(5) "fruit" + +string(6) "orange" +string(1) "a" +string(5) "fruit" + +string(6) "banana" +string(1) "b" +string(5) "fruit" + +string(5) "apple" +string(1) "c" +string(5) "fruit" + +bool(true) +-- Using array_walk with default parameters to show modified array contents -- +string(5) "lemon" +string(1) "d" + +string(6) "orange" +string(1) "a" + +string(6) "banana" +string(1) "b" + +string(5) "apple" +string(1) "c" + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_error1.phpt b/ext/standard/tests/array/array_walk_error1.phpt new file mode 100644 index 0000000000..014885a946 --- /dev/null +++ b/ext/standard/tests/array/array_walk_error1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test array_walk() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : error conditions *** +-- Testing array_walk() function with zero arguments -- + +Warning: array_walk() expects at least 2 parameters, 0 given in %s on line %d +NULL +-- Testing array_walk() function with one argument -- + +Warning: array_walk() expects at least 2 parameters, 1 given in %s on line %d +NULL +-- Testing array_walk() function with non existent callback function -- + +Warning: array_walk(): Unable to call non_existent() - function does not exist in %s on line %d +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_error2.phpt b/ext/standard/tests/array/array_walk_error2.phpt new file mode 100644 index 0000000000..654637ab5a --- /dev/null +++ b/ext/standard/tests/array/array_walk_error2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test array_walk() function : error conditions - callback parameters +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : error conditions - callback parameters *** + +Warning: Missing argument 3 for callback1() in %s on line %d + +callback1() invoked +bool(true) + +Warning: Missing argument 4 for callback2() in %s on line %d + +callback2() invoked +bool(true) + +callback1() invoked +bool(true) + +callback2() invoked +bool(true) +-- Testing array_walk() function with too many callback parameters -- + +Warning: array_walk() expects at most 3 parameters, 4 given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_walk_object1.phpt b/ext/standard/tests/array/array_walk_object1.phpt new file mode 100644 index 0000000000000000000000000000000000000000..632b651c0dadec9a2a1e97fad6cc5c9dc08f1cd5 GIT binary patch literal 1391 zcmbVMQES^k4DR#&3SkVjO}s37+LEnhv?&ZW2sDhrHp2O=HeQ`Ob3UgvqyK%63J6x}0Ax(^M?6b|9^l?do2ZcTo&CjaIHO8m3^fU#Q$*k!9gp0FkCw zpFYni`2BgcuEaQjg*DE&wnCt&%$RZ?(xXFI=&EresGTkJErgs#%MHT!5p0SF%pq)Q zw7GQhXDlFrORSYGDyA}pk5yH+Ac0*5KHv=C7Hta~++=iMZb0fTH88}rX{Rj4<>^Z$sA{h(fFQ@`p*UW2Ia-pFrCB+itsb_vlxVOy)wd1soW&4{v9ud{r zK#(K}u)GX=pzsl4$^VBAW}Xm{f6{acN|t3N)m^kxYAeeI2i@+l9YI0FLYe3Oh>KrH zOY%CjHT5L)W=O%mYx0KMVvCwSs4E>k4m$XS1WY0H{MUd!f1ik@$`Htm`Lmu9sjGg{ z=)4BE_KqDUP(6TVm?j4KX{~fsx-8$+udBdm);qChO(vz>i Lh?getValue()); + echo "key : "; + var_dump($key); +} + +function callback_public($value, $key) +{ + echo "value : "; + var_dump($value->pub_value); +} +function callback_protected($value, $key) +{ + echo "value : "; + var_dump($value->get_pro_value()); +} + +class MyClass +{ + private $pri_value; + public $pub_value; + protected $pro_value; + public function __construct($setVal) + { + $this->pri_value = $setVal; + $this->pub_value = $setVal; + $this->pro_value = $setVal; + } + public function getValue() + { + return $this->pri_value; + } + public function get_pro_value() + { + return $this->pro_value; + } +}; + +// array containing objects of MyClass +$input = array ( + new MyClass(3), + new MyClass(10), + new MyClass(20), + new MyClass(-10) +); + +echo "-- For private member --\n"; +var_dump( array_walk($input, "callback_private", 1)); +echo "-- For public member --\n"; +var_dump( array_walk($input, "callback_public")); +echo "-- For protected member --\n"; +var_dump( array_walk($input, "callback_protected")); + +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk() : array of objects *** +-- For private member -- +value : int(3) +key : int(0) +value : int(10) +key : int(1) +value : int(20) +key : int(2) +value : int(-10) +key : int(3) +bool(true) +-- For public member -- +value : int(3) +value : int(10) +value : int(20) +value : int(-10) +bool(true) +-- For protected member -- +value : int(3) +value : int(10) +value : int(20) +value : int(-10) +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_basic1.phpt b/ext/standard/tests/array/array_walk_recursive_basic1.phpt new file mode 100644 index 0000000000..df192b6a79 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_basic1.phpt @@ -0,0 +1,80 @@ +--TEST-- +Test array_walk_recursive() function : basic functionality - regular array +--FILE-- + +--EXPECT-- +*** Testing array_walk_recursive() : basic functionality *** +-- Using array_walk_recursive() with default parameters to show array contents -- +string(5) "lemon" +int(0) + +string(6) "orange" +int(0) + +string(6) "banana" +int(1) + +string(5) "apple" +int(0) + +bool(true) +-- Using array_walk_recursive() with all parameters -- +string(5) "lemon" +int(0) +string(5) "Added" + +string(6) "orange" +int(0) +string(5) "Added" + +string(6) "banana" +int(1) +string(5) "Added" + +string(5) "apple" +int(0) +string(5) "Added" + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_basic2.phpt b/ext/standard/tests/array/array_walk_recursive_basic2.phpt new file mode 100644 index 0000000000..c71d92b456 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_basic2.phpt @@ -0,0 +1,105 @@ +--TEST-- +Test array_walk_recursive() function : basic functionality - associative array +--FILE-- + "lemon", "b" => array( "c" => "orange", "d" => "banana"), "e" => array("f" => "apple")); + +// User defined callback functions +/* Prototype : test_alter(mixed $item, mixed $key, string $prefix) + * Parameters : item - value in key/value pair + * key - key in key/value pair + * prefix - string to be added + * Description : alters the array values by appending prefix string + */ +function test_alter(&$item, $key, $prefix) +{ + // dump the arguments to check that they are passed + // with proper type + var_dump($item); // value + var_dump($key); // key + var_dump($prefix); // additional agument passed to callback function + echo "\n"; // new line to separate the output between each element +} + +/* Prototype : test_print(mixed $item, mixed $key) + * Parameters : item - value in key/value pair + * key - key in key/value pair + * Description : prints the array values with keys + */ +function test_print($item, $key) +{ + // dump the arguments to check that they are passed + // with proper type + var_dump($item); // value + var_dump($key); // key + echo "\n"; // new line to separate the output between each element +} + +echo "-- Using array_walk_recursive with default parameters to show array contents --\n"; +var_dump(array_walk_recursive($fruits, 'test_print')); + +echo "-- Using array_walk_recursive with one optional parameter to modify contents --\n"; +var_dump (array_walk_recursive($fruits, 'test_alter', 'fruit')); + +echo "-- Using array_walk_recursive with default parameters to show modified array contents --\n"; +var_dump (array_walk_recursive($fruits, 'test_print')); + +echo "Done"; +?> +--EXPECT-- +*** Testing array_walk_recursive() : basic functionality *** +-- Using array_walk_recursive with default parameters to show array contents -- +string(5) "lemon" +string(1) "a" + +string(6) "orange" +string(1) "c" + +string(6) "banana" +string(1) "d" + +string(5) "apple" +string(1) "f" + +bool(true) +-- Using array_walk_recursive with one optional parameter to modify contents -- +string(5) "lemon" +string(1) "a" +string(5) "fruit" + +string(6) "orange" +string(1) "c" +string(5) "fruit" + +string(6) "banana" +string(1) "d" +string(5) "fruit" + +string(5) "apple" +string(1) "f" +string(5) "fruit" + +bool(true) +-- Using array_walk_recursive with default parameters to show modified array contents -- +string(5) "lemon" +string(1) "a" + +string(6) "orange" +string(1) "c" + +string(6) "banana" +string(1) "d" + +string(5) "apple" +string(1) "f" + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_error1.phpt b/ext/standard/tests/array/array_walk_recursive_error1.phpt new file mode 100644 index 0000000000..df7092c02b --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_error1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test array_walk_recursive() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : error conditions *** +-- Testing array_walk_recursive() function with zero arguments -- + +Warning: array_walk_recursive() expects at least 2 parameters, 0 given in %s on line %d +NULL +-- Testing array_walk_recursive() function with one argument -- + +Warning: array_walk_recursive() expects at least 2 parameters, 1 given in %s on line %d +NULL +-- Testing array_walk_recursive() function with non existent callback function -- + +Warning: array_walk_recursive(): Unable to call non_existent() - function does not exist in %s on line %d +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_error2.phpt b/ext/standard/tests/array/array_walk_recursive_error2.phpt new file mode 100644 index 0000000000..d628e9327a --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_error2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test array_walk_recursive() function : error conditions - callback parameters +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : error conditions - callback parameters *** + +Warning: Missing argument 3 for callback1() in %s on line %d + +callback1() invoked +bool(true) + +Warning: Missing argument 4 for callback2() in %s on line %d + +callback2() invoked +bool(true) + +callback1() invoked +bool(true) + +callback2() invoked +bool(true) +-- Testing array_walk_recursive() function with too many callback parameters -- + +Warning: array_walk_recursive() expects at most 3 parameters, 4 given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_walk_recursive_object1.phpt b/ext/standard/tests/array/array_walk_recursive_object1.phpt new file mode 100644 index 0000000000000000000000000000000000000000..30d03a70afeacbaffc657c72a16132be73253137 GIT binary patch literal 1441 zcmbtU+iKfD5Y6*`#UKQcgjLslYV9_mBn}iBFvOHXTg+-TiPgxvVzqK2O8&hwD@(cA zP^cdyd3G*m&Y9UXUCytTX)2ajJCN4Oc6BGq+m%Jt*t*za6vK6+l`D*fDVXdxDmPeU zS-2KJr0K<%uX9TC@w8f3Vw}Lj8fRQvAy8CiOu0X~uLxnGtHzC>cDB$r5OP5+HwZsQ zuqo~_hp?&9=F-Vuv48~5u~xRI7}OL#S5?`91a=vafir+xv@L9KlhJ{>2B|v`z$vaw zV-2$CcLrkv9rVEq8u6!}vJGY^g0c;tBsN|t3N)orxnY%9wK2L^Ak9YH}5 zLz(CPh-p|zOGG=gHR%+3Go;|(HF?7gjew>P(x(H;LC=06C8iL1{%b&Azc0k3We8-( z{Dry%>Y|@MIDmVQ>d#x(-Lcpy|mYv*NLe#UBCGHvMZh zRm8{f?3u+^d|`VGXWvd)FV2Gys-&rb%l3@lK6_=0t#k+>eXM*sj;flhEEE}=?1_=K zhxUvIzq00uy>lM=TCJ4Pv^9-#QCOqKgG&nR>teE$;k_d?L?7mQ#MlL(^Y`rK#? z#OVp$KlAU4`PuS2=qk+Oe&;l{|?j4KX{{y)X3Lf;DyyL71 T<=bic+LN!!hy=x0aChP_Y2DFi literal 0 HcmV?d00001 diff --git a/ext/standard/tests/array/array_walk_recursive_object2.phpt b/ext/standard/tests/array/array_walk_recursive_object2.phpt new file mode 100644 index 0000000000..aa12fe869a --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_object2.phpt @@ -0,0 +1,106 @@ +--TEST-- +Test array_walk_recursive() function : object functionality - array of objects +--FILE-- +getValue()); + echo "key : "; + var_dump($key); +} + +function callback_public($value, $key) +{ + echo "value : "; + var_dump($value->pub_value); +} +function callback_protected($value, $key) +{ + echo "value : "; + var_dump($value->get_pro_value()); +} + +class MyClass +{ + private $pri_value; + public $pub_value; + protected $pro_value; + public function __construct($setVal) + { + $this->pri_value = $setVal; + $this->pub_value = $setVal; + $this->pro_value = $setVal; + } + public function getValue() + { + return $this->pri_value; + } + public function get_pro_value() + { + return $this->pro_value; + } +}; + +// array containing objects of MyClass +$input = array ( + array( + new MyClass(3), + new MyClass(10), + ), + new MyClass(20), + array(new MyClass(-10)) +); + +echo "-- For private member --\n"; +var_dump( array_walk_recursive($input, "callback_private", 1)); +echo "-- For public member --\n"; +var_dump( array_walk_recursive($input, "callback_public")); +echo "-- For protected member --\n"; +var_dump( array_walk_recursive($input, "callback_protected")); + +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk_recursive() : array of objects *** +-- For private member -- +value : int(3) +key : int(0) +value : int(10) +key : int(1) +value : int(20) +key : int(1) +value : int(-10) +key : int(0) +bool(true) +-- For public member -- +value : int(3) +value : int(10) +value : int(20) +value : int(-10) +bool(true) +-- For protected member -- +value : int(3) +value : int(10) +value : int(20) +value : int(-10) +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation1.phpt b/ext/standard/tests/array/array_walk_recursive_variation1.phpt new file mode 100644 index 0000000000..2673df99a4 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation1.phpt @@ -0,0 +1,250 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - unexpected values for 'input' argument +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : unexpected values for 'input' argument *** +-- Iteration 1 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 11 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 12 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 14 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 21 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk_recursive(): The argument should be an array in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation2.phpt b/ext/standard/tests/array/array_walk_recursive_variation2.phpt new file mode 100644 index 0000000000..d946473763 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation2.phpt @@ -0,0 +1,271 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - unexpected values in place of 'funcname' argument(Bug#43543) +--FILE-- + 'red', 'item' => 'pen'), + + // null data +/* 14*/ NULL, + null, + + // boolean data +/* 16*/ true, + false, + TRUE, + FALSE, + + // empty data +/* 20*/ "", + '', + + // object data + new MyClass(), + + // resource data +/* 23*/ $fp, + + // undefined data + @$undefined_var, + + // unset data +/* 25*/ @$unset_var, +); + +for($count = 0; $count < count($funcname_values); $count++) { + echo "-- Iteration ".($count + 1)." --\n"; + var_dump( array_walk_recursive($input, $funcname_values[$count]) ); + var_dump( array_walk_recursive($input, $funcname_values[$count], $user_data )); +} + +fclose($fp); +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk_recursive() : unexpected values for 'funcname' argument *** +-- Iteration 1 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 11 -- + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 12 -- + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 13 -- + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk_recursive(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 14 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: array_walk_recursive(): Unable to call () - function does not exist in %s on line %d +bool(true) + +Warning: array_walk_recursive(): Unable to call () - function does not exist in %s on line %d +bool(true) +-- Iteration 21 -- + +Warning: array_walk_recursive(): Unable to call () - function does not exist in %s on line %d +bool(true) + +Warning: array_walk_recursive(): Unable to call () - function does not exist in %s on line %d +bool(true) +-- Iteration 22 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 23 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 24 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 25 -- + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk_recursive(): Wrong syntax for function name in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation3.phpt b/ext/standard/tests/array/array_walk_recursive_variation3.phpt new file mode 100644 index 0000000000..747ba3bb0f --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation3.phpt @@ -0,0 +1,123 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - 'input' array with different values +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : 'input' array with different values*** + +-- Iteration 1 -- +1 : 0 1 +1 : 1 0 +1 : 2 -10 +1 : 0 19 +1 : 1 -33 +1 : 0 90 +1 : 1 31 +1 : 2 -110 +bool(true) + +-- Iteration 2 -- +2 : 0 3.4 +2 : 1 0.8 +2 : 2 -2.9 +2 : 0 625 +2 : 1 0.0082 +bool(true) + +-- Iteration 3 -- +3 : 0 Mango +3 : 0 Apple +3 : 1 Orange +3 : 2 Lemon +bool(true) + +-- Iteration 4 -- +4 : 0 1 +4 : 1 +4 : 0 1 +4 : 1 +bool(true) + +-- Iteration 5 -- +5 : 0 +5 : 0 +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +7 : 0 binary +bool(true) + +-- Iteration 8 -- +8 : 0 16 +8 : 1 8.345 +8 : 0 Fruits +8 : 0 1 +8 : 1 +8 : 0 +8 : 0 -98 +8 : 1 0.005 +8 : 2 banana +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation4.phpt b/ext/standard/tests/array/array_walk_recursive_variation4.phpt new file mode 100644 index 0000000000..4db34979a4 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation4.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - 'input' array with subarray +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : array with subarray *** +int(0) +int(1) + +int(0) +int(1) + +int(1) +int(2) + +int(2) +int(3) + +int(0) +string(5) "Mango" + +int(1) +string(6) "Orange" + +int(0) +int(1) + +int(1) +int(2) + +int(2) +int(3) + +int(0) +int(1) + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation5.phpt b/ext/standard/tests/array/array_walk_recursive_variation5.phpt new file mode 100644 index 0000000000..688da57f01 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation5.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - 'input' argument containing reference variables +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : array with references *** +int(0) +int(10) + +int(0) +int(-20) + +int(1) +int(-35) + +int(0) +int(10) + +int(1) +int(0) + +int(0) +int(50) + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation6.phpt b/ext/standard/tests/array/array_walk_recursive_variation6.phpt new file mode 100644 index 0000000000..554ade4f4f --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation6.phpt @@ -0,0 +1,147 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - 'input' argument as diff. associative arrays +--FILE-- + array(1 => 25, 5 => 12, 0 => -80), 1 => array(-2 => 100, 5 => 30)); +echo "-- Associative array with numeric keys --\n"; +var_dump( array_walk_recursive($input, "for_numeric", 10)); + +// String keys +$input = array( "a" => "Apple", 'z' => array('b' => 'Bananna', "c" => "carrot"), 'x' => array('o' => "Orange")); +echo "-- Associative array with string keys --\n"; +var_dump( array_walk_recursive($input, "for_string")); + +// binary keys +$input = array( b"a" => "Apple", b"b" => "Banana"); +echo "-- Associative array with binary keys --\n"; +var_dump( array_walk_recursive($input, "for_string")); + +// Mixed keys - numeric/string +$input = array( 0 => array(0 => 1, 1 => 2), "x" => array("a" => "Apple", "b" => "Banana"), 2 =>3); +echo "-- Associative array with numeric/string keys --\n"; +var_dump( array_walk_recursive($input, "for_mixed")); + +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk_recursive() : 'input' as an associative array *** +-- Associative array with numeric keys -- +int(1) +int(25) +int(10) + +int(5) +int(12) +int(10) + +int(0) +int(-80) +int(10) + +int(-2) +int(100) +int(10) + +int(5) +int(30) +int(10) + +bool(true) +-- Associative array with string keys -- +string(1) "a" +string(5) "Apple" + +string(1) "b" +string(7) "Bananna" + +string(1) "c" +string(6) "carrot" + +string(1) "o" +string(6) "Orange" + +bool(true) +-- Associative array with binary keys -- +string(1) "a" +string(5) "Apple" + +string(1) "b" +string(6) "Banana" + +bool(true) +-- Associative array with numeric/string keys -- +int(0) +int(1) + +int(1) +int(2) + +string(1) "a" +string(5) "Apple" + +string(1) "b" +string(6) "Banana" + +int(2) +int(3) + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation7.phpt b/ext/standard/tests/array/array_walk_recursive_variation7.phpt new file mode 100644 index 0000000000..0cdd6d248d --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation7.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - anonymous callback function +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : anonymous function as callback *** +-- Anonymous function with one argument -- +int(2) + +int(5) + +int(10) + +int(0) + +bool(true) +-- Anonymous function with two arguments -- +int(0) +int(2) + +int(1) +int(5) + +int(0) +int(10) + +int(1) +int(0) + +bool(true) +-- Anonymous function with three arguments -- +int(0) +int(2) +int(10) + +int(1) +int(5) +int(10) + +int(0) +int(10) +int(10) + +int(1) +int(0) +int(10) + +bool(true) +-- Anonymous function with one more argument -- + +Warning: array_walk_recursive() expects at most 3 parameters, 4 given in %s on line %d +NULL +-- Anonymous function with null argument -- +1 +1 +1 +1 +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation8.phpt b/ext/standard/tests/array/array_walk_recursive_variation8.phpt new file mode 100644 index 0000000000..aa73912cfb --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation8.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - buit-in function as callback +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : built-in function as callback *** +-- With 'pow' built-in function -- +bool(true) +-- With 'min' built-in function -- +bool(true) +-- With 'echo' language construct -- + +Warning: array_walk_recursive(): Unable to call echo() - function does not exist in %s on line %d +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_recursive_variation9.phpt b/ext/standard/tests/array/array_walk_recursive_variation9.phpt new file mode 100644 index 0000000000..f18fe248c1 --- /dev/null +++ b/ext/standard/tests/array/array_walk_recursive_variation9.phpt @@ -0,0 +1,99 @@ +--TEST-- +Test array_walk_recursive() function : usage variations - different callback functions +--FILE-- + +--EXPECTF-- +*** Testing array_walk_recursive() : callback function variation *** +-- callback function with both parameters -- +int(0) +string(5) "Apple" + +int(1) +string(6) "Banana" + +int(1) +string(5) "Mango" + +int(0) +string(6) "Orange" + +bool(true) +-- callback function with only one parameter -- +string(5) "Apple" + +string(6) "Banana" + +string(5) "Mango" + +string(6) "Orange" + +bool(true) +-- callback function without parameters -- +callback3() called +callback3() called +callback3() called +callback3() called +bool(true) +-- passing one more parameter to function with two parameters -- +int(0) +string(5) "Apple" + +int(1) +string(6) "Banana" + +int(1) +string(5) "Mango" + +int(0) +string(6) "Orange" + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_variation1.phpt b/ext/standard/tests/array/array_walk_variation1.phpt new file mode 100644 index 0000000000..e08c0d7110 --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation1.phpt @@ -0,0 +1,250 @@ +--TEST-- +Test array_walk() function : usage variations - unexpected values for 'input' argument +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : unexpected values for 'input' argument *** +-- Iteration 1 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 11 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 12 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 14 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 21 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) + +Warning: array_walk(): The argument should be an array in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_walk_variation2.phpt b/ext/standard/tests/array/array_walk_variation2.phpt new file mode 100644 index 0000000000..88fbbf3d56 --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation2.phpt @@ -0,0 +1,271 @@ +--TEST-- +Test array_walk() function : usage variations - unexpected values in place of 'funcname' argument +--FILE-- + 'red', 'item' => 'pen'), + + // null data +/* 14*/ NULL, + null, + + // boolean data +/* 16*/ true, + false, + TRUE, + FALSE, + + // empty data +/* 20*/ "", + '', + + // object data + new MyClass(), + + // resource data +/* 23*/ $fp, + + // undefined data + @$undefined_var, + + // unset data +/* 25*/ @$unset_var, +); + +for($count = 0; $count < count($funcname_values); $count++) { + echo "-- Iteration ".($count + 1)." --\n"; + var_dump( array_walk($input, $funcname_values[$count]) ); + var_dump( array_walk($input, $funcname_values[$count], $user_data )); +} + +fclose($fp); +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk() : unexpected values for 'funcname' argument *** +-- Iteration 1 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 11 -- + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 12 -- + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 13 -- + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) + +Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d +bool(true) +-- Iteration 14 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: array_walk(): Unable to call () - function does not exist in %s on line %d +bool(true) + +Warning: array_walk(): Unable to call () - function does not exist in %s on line %d +bool(true) +-- Iteration 21 -- + +Warning: array_walk(): Unable to call () - function does not exist in %s on line %d +bool(true) + +Warning: array_walk(): Unable to call () - function does not exist in %s on line %d +bool(true) +-- Iteration 22 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 23 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 24 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +-- Iteration 25 -- + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) + +Warning: array_walk(): Wrong syntax for function name in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_walk_variation3.phpt b/ext/standard/tests/array/array_walk_variation3.phpt new file mode 100644 index 0000000000..ad26123536 --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation3.phpt @@ -0,0 +1,123 @@ +--TEST-- +Test array_walk() function : usage variations - 'input' array with different values +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : 'input' array with different values*** + +-- Iteration 1 -- +1 : 0 1 +1 : 1 0 +1 : 2 -10 +1 : 3 19 +1 : 4 -33 +1 : 5 90 +1 : 6 31 +1 : 7 -110 +bool(true) + +-- Iteration 2 -- +2 : 0 3.4 +2 : 1 0.8 +2 : 2 -2.9 +2 : 3 625 +2 : 4 0.0082 +bool(true) + +-- Iteration 3 -- +3 : 0 Mango +3 : 1 Apple +3 : 2 Orange +3 : 3 Lemon +bool(true) + +-- Iteration 4 -- +4 : 0 1 +4 : 1 +4 : 2 1 +4 : 3 +bool(true) + +-- Iteration 5 -- +5 : 0 +5 : 1 +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +7 : 0 binary +bool(true) + +-- Iteration 8 -- +8 : 0 16 +8 : 1 8.345 +8 : 2 Fruits +8 : 3 1 +8 : 4 +8 : 5 +8 : 6 -98 +8 : 7 0.005 +8 : 8 banana +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_variation4.phpt b/ext/standard/tests/array/array_walk_variation4.phpt new file mode 100644 index 0000000000..868732daaf --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation4.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test array_walk() function : usage variations - 'input' array with subarray +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : array with subarray *** +int(0) +array(0) { +} + +int(1) +array(1) { + [0]=> + int(1) +} + +int(2) +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} + +int(3) +array(2) { + [0]=> + string(5) "Mango" + [1]=> + string(6) "Orange" +} + +int(4) +array(1) { + [0]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_variation5.phpt b/ext/standard/tests/array/array_walk_variation5.phpt new file mode 100644 index 0000000000..f42e0f11e6 --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation5.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test array_walk() function : usage variations - 'input' argument containing reference variables +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : array with references *** +int(0) +int(10) + +int(1) +int(-20) + +int(2) +int(-35) + +int(3) +int(10) + +int(4) +int(0) + +int(5) +int(50) + +bool(true) +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_walk_variation6.phpt b/ext/standard/tests/array/array_walk_variation6.phpt new file mode 100644 index 0000000000..c1f23233ec --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation6.phpt @@ -0,0 +1,143 @@ +--TEST-- +Test array_walk() function : usage variations - 'input' argument as diff. associative arrays +--FILE-- + 25, 5 => 12, 0 => -80, -2 => 100, 5 => 30); +echo "-- Associative array with numeric keys --\n"; +var_dump( array_walk($input, "for_numeric", 10)); + +// String keys +$input = array( "a" => "Apple", 'b' => 'Bananna', "c" => "carrot", 'o' => "Orange"); +echo "-- Associative array with string keys --\n"; +var_dump( array_walk($input, "for_string")); + +// binary keys +$input = array( b"a" => "Apple", b"b" => "Banana"); +echo "-- Associative array with binary keys --\n"; +var_dump( array_walk($input, "for_string")); + +// Mixed keys - numeric/string +$input = array( 0 => 1, 1 => 2, "a" => "Apple", "b" => "Banana", 2 =>3); +echo "-- Associative array with numeric/string keys --\n"; +var_dump( array_walk($input, "for_mixed")); + +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk() : 'input' as an associative array *** +-- Associative array with numeric keys -- +int(1) +int(25) +int(10) + +int(5) +int(30) +int(10) + +int(0) +int(-80) +int(10) + +int(-2) +int(100) +int(10) + +bool(true) +-- Associative array with string keys -- +string(1) "a" +string(5) "Apple" + +string(1) "b" +string(7) "Bananna" + +string(1) "c" +string(6) "carrot" + +string(1) "o" +string(6) "Orange" + +bool(true) +-- Associative array with binary keys -- +string(1) "a" +string(5) "Apple" + +string(1) "b" +string(6) "Banana" + +bool(true) +-- Associative array with numeric/string keys -- +int(0) +int(1) + +int(1) +int(2) + +string(1) "a" +string(5) "Apple" + +string(1) "b" +string(6) "Banana" + +int(2) +int(3) + +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_variation7.phpt b/ext/standard/tests/array/array_walk_variation7.phpt new file mode 100644 index 0000000000..da85958b8e --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation7.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test array_walk() function : usage variations - anonymous callback function +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : anonymous function as callback *** +-- Anonymous function with one argument -- +int(2) + +int(5) + +int(10) + +int(0) + +bool(true) +-- Anonymous function with two arguments -- +int(0) +int(2) + +int(1) +int(5) + +int(2) +int(10) + +int(3) +int(0) + +bool(true) +-- Anonymous function with three arguments -- +int(0) +int(2) +int(10) + +int(1) +int(5) +int(10) + +int(2) +int(10) +int(10) + +int(3) +int(0) +int(10) + +bool(true) +-- Anonymous function with one more argument -- + +Warning: array_walk() expects at most 3 parameters, 4 given in %s on line %d +NULL +-- Anonymous function with null argument -- +1 +1 +1 +1 +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_variation8.phpt b/ext/standard/tests/array/array_walk_variation8.phpt new file mode 100644 index 0000000000..2086394dd0 --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation8.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test array_walk() function : usage variations - buit-in function as callback +--FILE-- + 1, 65, 98, 100, 6 => -4); + +echo "-- With 'pow' built-in function --\n"; +var_dump( array_walk($input, 'pow')); + +echo "-- With 'min' built-in function --\n"; +var_dump( array_walk($input, "min")); + +echo "-- With 'echo' language construct --\n"; +var_dump( array_walk($input, "echo")); + +echo "Done" +?> +--EXPECTF-- +*** Testing array_walk() : built-in function as callback *** +-- With 'pow' built-in function -- +bool(true) +-- With 'min' built-in function -- +bool(true) +-- With 'echo' language construct -- + +Warning: array_walk(): Unable to call echo() - function does not exist in %s on line %d +bool(true) +Done diff --git a/ext/standard/tests/array/array_walk_variation9.phpt b/ext/standard/tests/array/array_walk_variation9.phpt new file mode 100644 index 0000000000..42ae20d68f --- /dev/null +++ b/ext/standard/tests/array/array_walk_variation9.phpt @@ -0,0 +1,99 @@ +--TEST-- +Test array_walk() function : usage variations - different callback functions +--FILE-- + +--EXPECTF-- +*** Testing array_walk() : callback function variation *** +-- callback function with both parameters -- +int(0) +string(5) "Apple" + +int(1) +string(6) "Banana" + +int(2) +string(5) "Mango" + +int(3) +string(6) "Orange" + +bool(true) +-- callback function with only one parameter -- +string(5) "Apple" + +string(6) "Banana" + +string(5) "Mango" + +string(6) "Orange" + +bool(true) +-- callback function without parameters -- +callback3() called +callback3() called +callback3() called +callback3() called +bool(true) +-- passing one more parameter to function with two parameters -- +int(0) +string(5) "Apple" + +int(1) +string(6) "Banana" + +int(2) +string(5) "Mango" + +int(3) +string(6) "Orange" + +bool(true) +Done \ No newline at end of file -- 2.40.0