From f36aae329ade9ae9ddf32a9137cd64fee4aeb091 Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Mon, 15 Oct 2007 06:23:27 +0000 Subject: [PATCH] New testcases for array_reverse() function --- .../tests/array/array_reverse_basic1.phpt | 117 ++ .../tests/array/array_reverse_basic2.phpt | 93 ++ .../tests/array/array_reverse_error.phpt | 56 + .../tests/array/array_reverse_variation1.phpt | 583 +++++++++ .../tests/array/array_reverse_variation2.phpt | 730 +++++++++++ .../tests/array/array_reverse_variation3.phpt | 1121 +++++++++++++++++ .../tests/array/array_reverse_variation4.phpt | 672 ++++++++++ .../tests/array/array_reverse_variation5.phpt | 711 +++++++++++ .../tests/array/array_reverse_variation6.phpt | 373 ++++++ 9 files changed, 4456 insertions(+) create mode 100644 ext/standard/tests/array/array_reverse_basic1.phpt create mode 100644 ext/standard/tests/array/array_reverse_basic2.phpt create mode 100644 ext/standard/tests/array/array_reverse_error.phpt create mode 100644 ext/standard/tests/array/array_reverse_variation1.phpt create mode 100644 ext/standard/tests/array/array_reverse_variation2.phpt create mode 100644 ext/standard/tests/array/array_reverse_variation3.phpt create mode 100644 ext/standard/tests/array/array_reverse_variation4.phpt create mode 100644 ext/standard/tests/array/array_reverse_variation5.phpt create mode 100644 ext/standard/tests/array/array_reverse_variation6.phpt diff --git a/ext/standard/tests/array/array_reverse_basic1.phpt b/ext/standard/tests/array/array_reverse_basic1.phpt new file mode 100644 index 0000000000..4ad6594d0c --- /dev/null +++ b/ext/standard/tests/array/array_reverse_basic1.phpt @@ -0,0 +1,117 @@ +--TEST-- +Test array_reverse() function : basic functionality - simple array for 'array' argument +--FILE-- + +--EXPECTF-- +*** Testing array_reverse() : basic functionality *** +array(6) { + [0]=> + float(13.33) + [1]=> + int(10) + [2]=> + string(4) "blue" + [3]=> + string(3) "red" + [4]=> + string(5) "green" + [5]=> + string(1) "a" +} +array(6) { + [5]=> + float(13.33) + [4]=> + int(10) + [3]=> + string(4) "blue" + [2]=> + string(3) "red" + [1]=> + string(5) "green" + [0]=> + string(1) "a" +} +array(6) { + [0]=> + float(13.33) + [1]=> + int(10) + [2]=> + string(4) "blue" + [3]=> + string(3) "red" + [4]=> + string(5) "green" + [5]=> + string(1) "a" +} +Done +--UEXPECTF-- +*** Testing array_reverse() : basic functionality *** +array(6) { + [0]=> + float(13.33) + [1]=> + int(10) + [2]=> + unicode(4) "blue" + [3]=> + unicode(3) "red" + [4]=> + unicode(5) "green" + [5]=> + unicode(1) "a" +} +array(6) { + [5]=> + float(13.33) + [4]=> + int(10) + [3]=> + unicode(4) "blue" + [2]=> + unicode(3) "red" + [1]=> + unicode(5) "green" + [0]=> + unicode(1) "a" +} +array(6) { + [0]=> + float(13.33) + [1]=> + int(10) + [2]=> + unicode(4) "blue" + [3]=> + unicode(3) "red" + [4]=> + unicode(5) "green" + [5]=> + unicode(1) "a" +} +Done diff --git a/ext/standard/tests/array/array_reverse_basic2.phpt b/ext/standard/tests/array/array_reverse_basic2.phpt new file mode 100644 index 0000000000..657b01bce6 --- /dev/null +++ b/ext/standard/tests/array/array_reverse_basic2.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test array_reverse() function : basic functionality - associative array for 'array' argument +--FILE-- + "hello", 123 => "number", 'string' => 'blue', "10" => 13.33); + +// Calling array_reverse() with default arguments +var_dump( array_reverse($array) ); + +// Calling array_reverse() with all possible arguments +var_dump( array_reverse($array, true) ); // expects the keys to be preserved +var_dump( array_reverse($array, false) ); // expects the keys not to be preserved + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_reverse() : basic functionality *** +array(4) { + [0]=> + float(13.33) + ["string"]=> + string(4) "blue" + [1]=> + string(6) "number" + ["a"]=> + string(5) "hello" +} +array(4) { + [10]=> + float(13.33) + ["string"]=> + string(4) "blue" + [123]=> + string(6) "number" + ["a"]=> + string(5) "hello" +} +array(4) { + [0]=> + float(13.33) + ["string"]=> + string(4) "blue" + [1]=> + string(6) "number" + ["a"]=> + string(5) "hello" +} +Done +--UEXPECTF-- +*** Testing array_reverse() : basic functionality *** +array(4) { + [0]=> + float(13.33) + [u"string"]=> + unicode(4) "blue" + [1]=> + unicode(6) "number" + [u"a"]=> + unicode(5) "hello" +} +array(4) { + [10]=> + float(13.33) + [u"string"]=> + unicode(4) "blue" + [123]=> + unicode(6) "number" + [u"a"]=> + unicode(5) "hello" +} +array(4) { + [0]=> + float(13.33) + [u"string"]=> + unicode(4) "blue" + [1]=> + unicode(6) "number" + [u"a"]=> + unicode(5) "hello" +} +Done diff --git a/ext/standard/tests/array/array_reverse_error.phpt b/ext/standard/tests/array/array_reverse_error.phpt new file mode 100644 index 0000000000..964314456c --- /dev/null +++ b/ext/standard/tests/array/array_reverse_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test array_reverse() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing array_reverse() : error conditions *** + +-- Testing array_reverse() function with Zero arguments -- + +Warning: array_reverse() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing array_diff() function with more than expected no. of arguments -- + +Warning: array_reverse() expects at most 2 parameters, 3 given in %s on line %d +NULL + +Warning: array_reverse() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_reverse() : error conditions *** + +-- Testing array_reverse() function with Zero arguments -- + +Warning: array_reverse() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing array_diff() function with more than expected no. of arguments -- + +Warning: array_reverse() expects at most 2 parameters, 3 given in %s on line %d +NULL + +Warning: array_reverse() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_reverse_variation1.phpt b/ext/standard/tests/array/array_reverse_variation1.phpt new file mode 100644 index 0000000000..4c70df4d46 --- /dev/null +++ b/ext/standard/tests/array/array_reverse_variation1.phpt @@ -0,0 +1,583 @@ +--TEST-- +Test array_reverse() function : usage variations - unexpected values for 'array' argument +--FILE-- + +--EXPECTF-- +*** Testing array_reverse() : usage variations - unexpected values for 'array' argument *** + +-- Iteration 1 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 17 -- +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 18 -- +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 19 -- +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 20 -- +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 21 -- +Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 22 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 23 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- +Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_reverse() : usage variations - unexpected values for 'array' argument *** + +-- Iteration 1 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 19 -- +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- +Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 22 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 23 -- +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- +Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d +NULL + +Warning: array_reverse() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_reverse_variation2.phpt b/ext/standard/tests/array/array_reverse_variation2.phpt new file mode 100644 index 0000000000..0fd75d0e1b --- /dev/null +++ b/ext/standard/tests/array/array_reverse_variation2.phpt @@ -0,0 +1,730 @@ +--TEST-- +Test array_reverse() function : usage variations - unexpected values for 'preserve_keys' argument +--FILE-- + "green", "red", "blue", "red", "orange", "pink"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//get a resource variable +$fp = fopen(__FILE__, "r"); + +//get a class +class classA +{ + public function __toString(){ + return "Class A object"; + } +} + +//array of values to iterate over +$preserve_keys = array ( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 10.5e10, + 10.6E-10, + .5, + + // array data +/*10*/ array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data +/*15*/ NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data +/*21*/ + "", + '', + + // object data + new classA(), + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + // resource variable +/*26*/ $fp + +); + +// loop through each element of the array $preserve_keys to check the behavior of array_reverse() +$iterator = 1; +foreach($preserve_keys as $preserve_key) { + echo "-- Iteration $iterator --\n"; + var_dump( array_reverse($array, $preserve_key) ); + $iterator++; +}; + +// close the file resouce used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_reverse() : usage variations *** +-- Iteration 1 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 2 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 3 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 4 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 5 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 6 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 7 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 8 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 9 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 10 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 15 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 16 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 17 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 18 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 19 -- +array(6) { + [4]=> + string(4) "pink" + [3]=> + string(6) "orange" + [2]=> + string(3) "red" + [1]=> + string(4) "blue" + [0]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 20 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 21 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 22 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 23 -- + +Warning: array_reverse() expects parameter 2 to be boolean, object given in %s on line %d +NULL +-- Iteration 24 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 25 -- +array(6) { + [0]=> + string(4) "pink" + [1]=> + string(6) "orange" + [2]=> + string(3) "red" + [3]=> + string(4) "blue" + [4]=> + string(3) "red" + ["a"]=> + string(5) "green" +} +-- Iteration 26 -- + +Warning: array_reverse() expects parameter 2 to be boolean, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_reverse() : usage variations *** +-- Iteration 1 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 2 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 3 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 4 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 5 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 6 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 7 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 8 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 9 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 10 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: array_reverse() expects parameter 2 to be boolean, array given in %s on line %d +NULL +-- Iteration 15 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 16 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 17 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 18 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 19 -- +array(6) { + [4]=> + unicode(4) "pink" + [3]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [1]=> + unicode(4) "blue" + [0]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 20 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 21 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 22 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 23 -- + +Warning: array_reverse() expects parameter 2 to be boolean, object given in %s on line %d +NULL +-- Iteration 24 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 25 -- +array(6) { + [0]=> + unicode(4) "pink" + [1]=> + unicode(6) "orange" + [2]=> + unicode(3) "red" + [3]=> + unicode(4) "blue" + [4]=> + unicode(3) "red" + [u"a"]=> + unicode(5) "green" +} +-- Iteration 26 -- + +Warning: array_reverse() expects parameter 2 to be boolean, resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_reverse_variation3.phpt b/ext/standard/tests/array/array_reverse_variation3.phpt new file mode 100644 index 0000000000..51723d3039 --- /dev/null +++ b/ext/standard/tests/array/array_reverse_variation3.phpt @@ -0,0 +1,1121 @@ +--TEST-- +Test array_reverse() function : usage variations - different array values for 'array' argument +--FILE-- + "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values + array("one" => 1, "two" => 2, "three" => 3 ), // string keys & numeric values + array( 1 => 10, 2 => 20, 4 => 40, 3 => 30), // explicit numeric keys and numeric values + array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value + array("one" => 1, 2 => "two", 4 => "four"), //mixed + + // associative array, containing null/empty/boolean values as key/value +/*13*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null), + array(true => "true", false => "false", "false" => false, "true" => true), + array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''), + array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true), + array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6), + + // array with repetative keys +/*18*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3) +); + +// loop through the various elements of $arrays to test array_reverse() +$iterator = 1; +foreach($arrays as $array) { + echo "-- Iteration $iterator --\n"; + // with default argument + echo "- with default argument -\n"; + var_dump( array_reverse($array) ); + // with all possible arguments + echo "- with \$preserve keys = true -\n"; + var_dump( array_reverse($array, true) ); + echo "- with \$preserve_keys = false -\n"; + var_dump( array_reverse($array, false) ); + $iterator++; +}; + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_reverse() : usage variations *** +-- Iteration 1 -- +- with default argument - +array(2) { + [0]=> + int(2) + [1]=> + int(1) +} +- with $preserve keys = true - +array(2) { + [1]=> + int(2) + [0]=> + int(1) +} +- with $preserve_keys = false - +array(2) { + [0]=> + int(2) + [1]=> + int(1) +} +-- Iteration 2 -- +- with default argument - +array(2) { + [0]=> + float(2.2) + [1]=> + float(1.1) +} +- with $preserve keys = true - +array(2) { + [1]=> + float(2.2) + [0]=> + float(1.1) +} +- with $preserve_keys = false - +array(2) { + [0]=> + float(2.2) + [1]=> + float(1.1) +} +-- Iteration 3 -- +- with default argument - +array(2) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(1) { + [0]=> + int(2) + } +} +- with $preserve keys = true - +array(2) { + [1]=> + array(1) { + [0]=> + int(1) + } + [0]=> + array(1) { + [0]=> + int(2) + } +} +- with $preserve_keys = false - +array(2) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(1) { + [0]=> + int(2) + } +} +-- Iteration 4 -- +- with default argument - +array(2) { + [0]=> + bool(true) + [1]=> + bool(false) +} +- with $preserve keys = true - +array(2) { + [1]=> + bool(true) + [0]=> + bool(false) +} +- with $preserve_keys = false - +array(2) { + [0]=> + bool(true) + [1]=> + bool(false) +} +-- Iteration 5 -- +- with default argument - +array(0) { +} +- with $preserve keys = true - +array(0) { +} +- with $preserve_keys = false - +array(0) { +} +-- Iteration 6 -- +- with default argument - +array(1) { + [0]=> + NULL +} +- with $preserve keys = true - +array(1) { + [0]=> + NULL +} +- with $preserve_keys = false - +array(1) { + [0]=> + NULL +} +-- Iteration 7 -- +- with default argument - +array(6) { + [0]=> + string(5) "ccccc" + [1]=> + string(1) "c" + [2]=> + string(4) "bbbb" + [3]=> + string(1) "b" + [4]=> + string(4) "aaaa" + [5]=> + string(1) "a" +} +- with $preserve keys = true - +array(6) { + [5]=> + string(5) "ccccc" + [4]=> + string(1) "c" + [3]=> + string(4) "bbbb" + [2]=> + string(1) "b" + [1]=> + string(4) "aaaa" + [0]=> + string(1) "a" +} +- with $preserve_keys = false - +array(6) { + [0]=> + string(5) "ccccc" + [1]=> + string(1) "c" + [2]=> + string(4) "bbbb" + [3]=> + string(1) "b" + [4]=> + string(4) "aaaa" + [5]=> + string(1) "a" +} +-- Iteration 8 -- +- with default argument - +array(3) { + [0]=> + string(5) "three" + [1]=> + string(3) "two" + [2]=> + string(3) "one" +} +- with $preserve keys = true - +array(3) { + [3]=> + string(5) "three" + [2]=> + string(3) "two" + [1]=> + string(3) "one" +} +- with $preserve_keys = false - +array(3) { + [0]=> + string(5) "three" + [1]=> + string(3) "two" + [2]=> + string(3) "one" +} +-- Iteration 9 -- +- with default argument - +array(3) { + ["three"]=> + int(3) + ["two"]=> + int(2) + ["one"]=> + int(1) +} +- with $preserve keys = true - +array(3) { + ["three"]=> + int(3) + ["two"]=> + int(2) + ["one"]=> + int(1) +} +- with $preserve_keys = false - +array(3) { + ["three"]=> + int(3) + ["two"]=> + int(2) + ["one"]=> + int(1) +} +-- Iteration 10 -- +- with default argument - +array(4) { + [0]=> + int(30) + [1]=> + int(40) + [2]=> + int(20) + [3]=> + int(10) +} +- with $preserve keys = true - +array(4) { + [3]=> + int(30) + [4]=> + int(40) + [2]=> + int(20) + [1]=> + int(10) +} +- with $preserve_keys = false - +array(4) { + [0]=> + int(30) + [1]=> + int(40) + [2]=> + int(20) + [3]=> + int(10) +} +-- Iteration 11 -- +- with default argument - +array(3) { + ["three"]=> + string(6) "thirty" + ["two"]=> + string(6) "twenty" + ["one"]=> + string(3) "ten" +} +- with $preserve keys = true - +array(3) { + ["three"]=> + string(6) "thirty" + ["two"]=> + string(6) "twenty" + ["one"]=> + string(3) "ten" +} +- with $preserve_keys = false - +array(3) { + ["three"]=> + string(6) "thirty" + ["two"]=> + string(6) "twenty" + ["one"]=> + string(3) "ten" +} +-- Iteration 12 -- +- with default argument - +array(3) { + [0]=> + string(4) "four" + [1]=> + string(3) "two" + ["one"]=> + int(1) +} +- with $preserve keys = true - +array(3) { + [4]=> + string(4) "four" + [2]=> + string(3) "two" + ["one"]=> + int(1) +} +- with $preserve_keys = false - +array(3) { + [0]=> + string(4) "four" + [1]=> + string(3) "two" + ["one"]=> + int(1) +} +-- Iteration 13 -- +- with default argument - +array(3) { + ["null"]=> + NULL + ["NULL"]=> + NULL + [""]=> + string(4) "null" +} +- with $preserve keys = true - +array(3) { + ["null"]=> + NULL + ["NULL"]=> + NULL + [""]=> + string(4) "null" +} +- with $preserve_keys = false - +array(3) { + ["null"]=> + NULL + ["NULL"]=> + NULL + [""]=> + string(4) "null" +} +-- Iteration 14 -- +- with default argument - +array(4) { + ["true"]=> + bool(true) + ["false"]=> + bool(false) + [0]=> + string(5) "false" + [1]=> + string(4) "true" +} +- with $preserve keys = true - +array(4) { + ["true"]=> + bool(true) + ["false"]=> + bool(false) + [0]=> + string(5) "false" + [1]=> + string(4) "true" +} +- with $preserve_keys = false - +array(4) { + ["true"]=> + bool(true) + ["false"]=> + bool(false) + [0]=> + string(5) "false" + [1]=> + string(4) "true" +} +-- Iteration 15 -- +- with default argument - +array(3) { + ["emptys"]=> + string(0) "" + ["emptyd"]=> + string(0) "" + [""]=> + string(6) "emptys" +} +- with $preserve keys = true - +array(3) { + ["emptys"]=> + string(0) "" + ["emptyd"]=> + string(0) "" + [""]=> + string(6) "emptys" +} +- with $preserve_keys = false - +array(3) { + ["emptys"]=> + string(0) "" + ["emptyd"]=> + string(0) "" + [""]=> + string(6) "emptys" +} +-- Iteration 16 -- +- with default argument - +array(6) { + [0]=> + bool(true) + [1]=> + bool(false) + [2]=> + NULL + [3]=> + NULL + [4]=> + string(0) "" + [5]=> + string(0) "" +} +- with $preserve keys = true - +array(6) { + [6]=> + bool(true) + [5]=> + bool(false) + [4]=> + NULL + [3]=> + NULL + [2]=> + string(0) "" + [1]=> + string(0) "" +} +- with $preserve_keys = false - +array(6) { + [0]=> + bool(true) + [1]=> + bool(false) + [2]=> + NULL + [3]=> + NULL + [4]=> + string(0) "" + [5]=> + string(0) "" +} +-- Iteration 17 -- +- with default argument - +array(3) { + [0]=> + int(6) + [1]=> + int(5) + [""]=> + int(4) +} +- with $preserve keys = true - +array(3) { + [1]=> + int(6) + [0]=> + int(5) + [""]=> + int(4) +} +- with $preserve_keys = false - +array(3) { + [0]=> + int(6) + [1]=> + int(5) + [""]=> + int(4) +} +-- Iteration 18 -- +- with default argument - +array(3) { + ["three"]=> + int(3) + ["two"]=> + int(20) + ["One"]=> + int(10) +} +- with $preserve keys = true - +array(3) { + ["three"]=> + int(3) + ["two"]=> + int(20) + ["One"]=> + int(10) +} +- with $preserve_keys = false - +array(3) { + ["three"]=> + int(3) + ["two"]=> + int(20) + ["One"]=> + int(10) +} +Done +--UEXPECTF-- +*** Testing array_reverse() : usage variations *** +-- Iteration 1 -- +- with default argument - +array(2) { + [0]=> + int(2) + [1]=> + int(1) +} +- with $preserve keys = true - +array(2) { + [1]=> + int(2) + [0]=> + int(1) +} +- with $preserve_keys = false - +array(2) { + [0]=> + int(2) + [1]=> + int(1) +} +-- Iteration 2 -- +- with default argument - +array(2) { + [0]=> + float(2.2) + [1]=> + float(1.1) +} +- with $preserve keys = true - +array(2) { + [1]=> + float(2.2) + [0]=> + float(1.1) +} +- with $preserve_keys = false - +array(2) { + [0]=> + float(2.2) + [1]=> + float(1.1) +} +-- Iteration 3 -- +- with default argument - +array(2) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(1) { + [0]=> + int(2) + } +} +- with $preserve keys = true - +array(2) { + [1]=> + array(1) { + [0]=> + int(1) + } + [0]=> + array(1) { + [0]=> + int(2) + } +} +- with $preserve_keys = false - +array(2) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(1) { + [0]=> + int(2) + } +} +-- Iteration 4 -- +- with default argument - +array(2) { + [0]=> + bool(true) + [1]=> + bool(false) +} +- with $preserve keys = true - +array(2) { + [1]=> + bool(true) + [0]=> + bool(false) +} +- with $preserve_keys = false - +array(2) { + [0]=> + bool(true) + [1]=> + bool(false) +} +-- Iteration 5 -- +- with default argument - +array(0) { +} +- with $preserve keys = true - +array(0) { +} +- with $preserve_keys = false - +array(0) { +} +-- Iteration 6 -- +- with default argument - +array(1) { + [0]=> + NULL +} +- with $preserve keys = true - +array(1) { + [0]=> + NULL +} +- with $preserve_keys = false - +array(1) { + [0]=> + NULL +} +-- Iteration 7 -- +- with default argument - +array(6) { + [0]=> + unicode(5) "ccccc" + [1]=> + unicode(1) "c" + [2]=> + unicode(4) "bbbb" + [3]=> + unicode(1) "b" + [4]=> + unicode(4) "aaaa" + [5]=> + unicode(1) "a" +} +- with $preserve keys = true - +array(6) { + [5]=> + unicode(5) "ccccc" + [4]=> + unicode(1) "c" + [3]=> + unicode(4) "bbbb" + [2]=> + unicode(1) "b" + [1]=> + unicode(4) "aaaa" + [0]=> + unicode(1) "a" +} +- with $preserve_keys = false - +array(6) { + [0]=> + unicode(5) "ccccc" + [1]=> + unicode(1) "c" + [2]=> + unicode(4) "bbbb" + [3]=> + unicode(1) "b" + [4]=> + unicode(4) "aaaa" + [5]=> + unicode(1) "a" +} +-- Iteration 8 -- +- with default argument - +array(3) { + [0]=> + unicode(5) "three" + [1]=> + unicode(3) "two" + [2]=> + unicode(3) "one" +} +- with $preserve keys = true - +array(3) { + [3]=> + unicode(5) "three" + [2]=> + unicode(3) "two" + [1]=> + unicode(3) "one" +} +- with $preserve_keys = false - +array(3) { + [0]=> + unicode(5) "three" + [1]=> + unicode(3) "two" + [2]=> + unicode(3) "one" +} +-- Iteration 9 -- +- with default argument - +array(3) { + [u"three"]=> + int(3) + [u"two"]=> + int(2) + [u"one"]=> + int(1) +} +- with $preserve keys = true - +array(3) { + [u"three"]=> + int(3) + [u"two"]=> + int(2) + [u"one"]=> + int(1) +} +- with $preserve_keys = false - +array(3) { + [u"three"]=> + int(3) + [u"two"]=> + int(2) + [u"one"]=> + int(1) +} +-- Iteration 10 -- +- with default argument - +array(4) { + [0]=> + int(30) + [1]=> + int(40) + [2]=> + int(20) + [3]=> + int(10) +} +- with $preserve keys = true - +array(4) { + [3]=> + int(30) + [4]=> + int(40) + [2]=> + int(20) + [1]=> + int(10) +} +- with $preserve_keys = false - +array(4) { + [0]=> + int(30) + [1]=> + int(40) + [2]=> + int(20) + [3]=> + int(10) +} +-- Iteration 11 -- +- with default argument - +array(3) { + [u"three"]=> + unicode(6) "thirty" + [u"two"]=> + unicode(6) "twenty" + [u"one"]=> + unicode(3) "ten" +} +- with $preserve keys = true - +array(3) { + [u"three"]=> + unicode(6) "thirty" + [u"two"]=> + unicode(6) "twenty" + [u"one"]=> + unicode(3) "ten" +} +- with $preserve_keys = false - +array(3) { + [u"three"]=> + unicode(6) "thirty" + [u"two"]=> + unicode(6) "twenty" + [u"one"]=> + unicode(3) "ten" +} +-- Iteration 12 -- +- with default argument - +array(3) { + [0]=> + unicode(4) "four" + [1]=> + unicode(3) "two" + [u"one"]=> + int(1) +} +- with $preserve keys = true - +array(3) { + [4]=> + unicode(4) "four" + [2]=> + unicode(3) "two" + [u"one"]=> + int(1) +} +- with $preserve_keys = false - +array(3) { + [0]=> + unicode(4) "four" + [1]=> + unicode(3) "two" + [u"one"]=> + int(1) +} +-- Iteration 13 -- +- with default argument - +array(3) { + [u"null"]=> + NULL + [u"NULL"]=> + NULL + [u""]=> + unicode(4) "null" +} +- with $preserve keys = true - +array(3) { + [u"null"]=> + NULL + [u"NULL"]=> + NULL + [u""]=> + unicode(4) "null" +} +- with $preserve_keys = false - +array(3) { + [u"null"]=> + NULL + [u"NULL"]=> + NULL + [u""]=> + unicode(4) "null" +} +-- Iteration 14 -- +- with default argument - +array(4) { + [u"true"]=> + bool(true) + [u"false"]=> + bool(false) + [0]=> + unicode(5) "false" + [1]=> + unicode(4) "true" +} +- with $preserve keys = true - +array(4) { + [u"true"]=> + bool(true) + [u"false"]=> + bool(false) + [0]=> + unicode(5) "false" + [1]=> + unicode(4) "true" +} +- with $preserve_keys = false - +array(4) { + [u"true"]=> + bool(true) + [u"false"]=> + bool(false) + [0]=> + unicode(5) "false" + [1]=> + unicode(4) "true" +} +-- Iteration 15 -- +- with default argument - +array(3) { + [u"emptys"]=> + unicode(0) "" + [u"emptyd"]=> + unicode(0) "" + [u""]=> + unicode(6) "emptys" +} +- with $preserve keys = true - +array(3) { + [u"emptys"]=> + unicode(0) "" + [u"emptyd"]=> + unicode(0) "" + [u""]=> + unicode(6) "emptys" +} +- with $preserve_keys = false - +array(3) { + [u"emptys"]=> + unicode(0) "" + [u"emptyd"]=> + unicode(0) "" + [u""]=> + unicode(6) "emptys" +} +-- Iteration 16 -- +- with default argument - +array(6) { + [0]=> + bool(true) + [1]=> + bool(false) + [2]=> + NULL + [3]=> + NULL + [4]=> + unicode(0) "" + [5]=> + unicode(0) "" +} +- with $preserve keys = true - +array(6) { + [6]=> + bool(true) + [5]=> + bool(false) + [4]=> + NULL + [3]=> + NULL + [2]=> + unicode(0) "" + [1]=> + unicode(0) "" +} +- with $preserve_keys = false - +array(6) { + [0]=> + bool(true) + [1]=> + bool(false) + [2]=> + NULL + [3]=> + NULL + [4]=> + unicode(0) "" + [5]=> + unicode(0) "" +} +-- Iteration 17 -- +- with default argument - +array(3) { + [0]=> + int(6) + [1]=> + int(5) + [u""]=> + int(4) +} +- with $preserve keys = true - +array(3) { + [1]=> + int(6) + [0]=> + int(5) + [u""]=> + int(4) +} +- with $preserve_keys = false - +array(3) { + [0]=> + int(6) + [1]=> + int(5) + [u""]=> + int(4) +} +-- Iteration 18 -- +- with default argument - +array(3) { + [u"three"]=> + int(3) + [u"two"]=> + int(20) + [u"One"]=> + int(10) +} +- with $preserve keys = true - +array(3) { + [u"three"]=> + int(3) + [u"two"]=> + int(20) + [u"One"]=> + int(10) +} +- with $preserve_keys = false - +array(3) { + [u"three"]=> + int(3) + [u"two"]=> + int(20) + [u"One"]=> + int(10) +} +Done diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt new file mode 100644 index 0000000000..9dcf5f8fe0 --- /dev/null +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -0,0 +1,672 @@ +--TEST-- +Test array_reverse() function : usage variations - assoc. array with diff. keys for 'array' argument +--FILE-- + "0"), + array(1 => "1"), + array(1 => "1", 2 => "2", 3 => "3", 4 => "4"), + + // arrays with float keys +/*5*/ array(2.3333 => "float"), + array(1.2 => "f1", 3.33 => "f2", 4.89999922839999 => "f3", 33333333.333333 => "f4"), + + // arrays with string keys + array("\tHello" => 111, "re\td" => "color", "\v\fworld" => 2.2, "pen\n" => 33), +/*8*/ array("\tHello" => 111, "re\td" => "color", "\v\fworld" => 2.2, "pen\n" => 33), + array("hello", $heredoc => "string"), // heredoc + + // array with object, unset variable and resource variable + array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), + + // array with mixed values +/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") +); + +// loop through the various elements of $arrays to test array_reverse() +$iterator = 1; +foreach($arrays as $array) { + echo "-- Iteration $iterator --\n"; + // with default argument + echo "- default argument -\n"; + var_dump( array_reverse($array) ); + // with $preserve_keys argument + echo "- \$preserve keys = true -\n"; + var_dump( array_reverse($array, true) ); + echo "- \$preserve_keys = false -\n"; + var_dump( array_reverse($array, false) ); + $iterator++; +}; + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_reverse() : usage variations *** + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d +-- Iteration 1 -- +- default argument - +array(0) { +} +- $preserve keys = true - +array(0) { +} +- $preserve_keys = false - +array(0) { +} +-- Iteration 2 -- +- default argument - +array(1) { + [0]=> + string(1) "0" +} +- $preserve keys = true - +array(1) { + [0]=> + string(1) "0" +} +- $preserve_keys = false - +array(1) { + [0]=> + string(1) "0" +} +-- Iteration 3 -- +- default argument - +array(1) { + [0]=> + string(1) "1" +} +- $preserve keys = true - +array(1) { + [1]=> + string(1) "1" +} +- $preserve_keys = false - +array(1) { + [0]=> + string(1) "1" +} +-- Iteration 4 -- +- default argument - +array(4) { + [0]=> + string(1) "4" + [1]=> + string(1) "3" + [2]=> + string(1) "2" + [3]=> + string(1) "1" +} +- $preserve keys = true - +array(4) { + [4]=> + string(1) "4" + [3]=> + string(1) "3" + [2]=> + string(1) "2" + [1]=> + string(1) "1" +} +- $preserve_keys = false - +array(4) { + [0]=> + string(1) "4" + [1]=> + string(1) "3" + [2]=> + string(1) "2" + [3]=> + string(1) "1" +} +-- Iteration 5 -- +- default argument - +array(1) { + [0]=> + string(5) "float" +} +- $preserve keys = true - +array(1) { + [2]=> + string(5) "float" +} +- $preserve_keys = false - +array(1) { + [0]=> + string(5) "float" +} +-- Iteration 6 -- +- default argument - +array(4) { + [0]=> + string(2) "f4" + [1]=> + string(2) "f3" + [2]=> + string(2) "f2" + [3]=> + string(2) "f1" +} +- $preserve keys = true - +array(4) { + [33333333]=> + string(2) "f4" + [4]=> + string(2) "f3" + [3]=> + string(2) "f2" + [1]=> + string(2) "f1" +} +- $preserve_keys = false - +array(4) { + [0]=> + string(2) "f4" + [1]=> + string(2) "f3" + [2]=> + string(2) "f2" + [3]=> + string(2) "f1" +} +-- Iteration 7 -- +- default argument - +array(4) { + ["pen +"]=> + int(33) + [" world"]=> + float(2.2) + ["re d"]=> + string(5) "color" + [" Hello"]=> + int(111) +} +- $preserve keys = true - +array(4) { + ["pen +"]=> + int(33) + [" world"]=> + float(2.2) + ["re d"]=> + string(5) "color" + [" Hello"]=> + int(111) +} +- $preserve_keys = false - +array(4) { + ["pen +"]=> + int(33) + [" world"]=> + float(2.2) + ["re d"]=> + string(5) "color" + [" Hello"]=> + int(111) +} +-- Iteration 8 -- +- default argument - +array(4) { + ["pen +"]=> + int(33) + [" world"]=> + float(2.2) + ["re d"]=> + string(5) "color" + [" Hello"]=> + int(111) +} +- $preserve keys = true - +array(4) { + ["pen +"]=> + int(33) + [" world"]=> + float(2.2) + ["re d"]=> + string(5) "color" + [" Hello"]=> + int(111) +} +- $preserve_keys = false - +array(4) { + ["pen +"]=> + int(33) + [" world"]=> + float(2.2) + ["re d"]=> + string(5) "color" + [" Hello"]=> + int(111) +} +-- Iteration 9 -- +- default argument - +array(2) { + ["Hello world"]=> + string(6) "string" + [0]=> + string(5) "hello" +} +- $preserve keys = true - +array(2) { + ["Hello world"]=> + string(6) "string" + [0]=> + string(5) "hello" +} +- $preserve_keys = false - +array(2) { + ["Hello world"]=> + string(6) "string" + [0]=> + string(5) "hello" +} +-- Iteration 10 -- +- default argument - +array(1) { + [""]=> + string(5) "hello" +} +- $preserve keys = true - +array(1) { + [""]=> + string(5) "hello" +} +- $preserve_keys = false - +array(1) { + [""]=> + string(5) "hello" +} +-- Iteration 11 -- +- default argument - +array(6) { + ["Hello world"]=> + string(7) "heredoc" + [""]=> + string(5) "unset" + [0]=> + string(5) "float" + [1]=> + string(3) "int" + ["fruit"]=> + float(2.2) + ["hello"]=> + int(1) +} +- $preserve keys = true - +array(6) { + ["Hello world"]=> + string(7) "heredoc" + [""]=> + string(5) "unset" + [444]=> + string(5) "float" + [133]=> + string(3) "int" + ["fruit"]=> + float(2.2) + ["hello"]=> + int(1) +} +- $preserve_keys = false - +array(6) { + ["Hello world"]=> + string(7) "heredoc" + [""]=> + string(5) "unset" + [0]=> + string(5) "float" + [1]=> + string(3) "int" + ["fruit"]=> + float(2.2) + ["hello"]=> + int(1) +} +Done +--UEXPECTF-- +*** Testing array_reverse() : usage variations *** + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d +-- Iteration 1 -- +- default argument - +array(0) { +} +- $preserve keys = true - +array(0) { +} +- $preserve_keys = false - +array(0) { +} +-- Iteration 2 -- +- default argument - +array(1) { + [0]=> + unicode(1) "0" +} +- $preserve keys = true - +array(1) { + [0]=> + unicode(1) "0" +} +- $preserve_keys = false - +array(1) { + [0]=> + unicode(1) "0" +} +-- Iteration 3 -- +- default argument - +array(1) { + [0]=> + unicode(1) "1" +} +- $preserve keys = true - +array(1) { + [1]=> + unicode(1) "1" +} +- $preserve_keys = false - +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 4 -- +- default argument - +array(4) { + [0]=> + unicode(1) "4" + [1]=> + unicode(1) "3" + [2]=> + unicode(1) "2" + [3]=> + unicode(1) "1" +} +- $preserve keys = true - +array(4) { + [4]=> + unicode(1) "4" + [3]=> + unicode(1) "3" + [2]=> + unicode(1) "2" + [1]=> + unicode(1) "1" +} +- $preserve_keys = false - +array(4) { + [0]=> + unicode(1) "4" + [1]=> + unicode(1) "3" + [2]=> + unicode(1) "2" + [3]=> + unicode(1) "1" +} +-- Iteration 5 -- +- default argument - +array(1) { + [0]=> + unicode(5) "float" +} +- $preserve keys = true - +array(1) { + [2]=> + unicode(5) "float" +} +- $preserve_keys = false - +array(1) { + [0]=> + unicode(5) "float" +} +-- Iteration 6 -- +- default argument - +array(4) { + [0]=> + unicode(2) "f4" + [1]=> + unicode(2) "f3" + [2]=> + unicode(2) "f2" + [3]=> + unicode(2) "f1" +} +- $preserve keys = true - +array(4) { + [33333333]=> + unicode(2) "f4" + [4]=> + unicode(2) "f3" + [3]=> + unicode(2) "f2" + [1]=> + unicode(2) "f1" +} +- $preserve_keys = false - +array(4) { + [0]=> + unicode(2) "f4" + [1]=> + unicode(2) "f3" + [2]=> + unicode(2) "f2" + [3]=> + unicode(2) "f1" +} +-- Iteration 7 -- +- default argument - +array(4) { + [u"pen +"]=> + int(33) + [u" world"]=> + float(2.2) + [u"re d"]=> + unicode(5) "color" + [u" Hello"]=> + int(111) +} +- $preserve keys = true - +array(4) { + [u"pen +"]=> + int(33) + [u" world"]=> + float(2.2) + [u"re d"]=> + unicode(5) "color" + [u" Hello"]=> + int(111) +} +- $preserve_keys = false - +array(4) { + [u"pen +"]=> + int(33) + [u" world"]=> + float(2.2) + [u"re d"]=> + unicode(5) "color" + [u" Hello"]=> + int(111) +} +-- Iteration 8 -- +- default argument - +array(4) { + [u"pen +"]=> + int(33) + [u" world"]=> + float(2.2) + [u"re d"]=> + unicode(5) "color" + [u" Hello"]=> + int(111) +} +- $preserve keys = true - +array(4) { + [u"pen +"]=> + int(33) + [u" world"]=> + float(2.2) + [u"re d"]=> + unicode(5) "color" + [u" Hello"]=> + int(111) +} +- $preserve_keys = false - +array(4) { + [u"pen +"]=> + int(33) + [u" world"]=> + float(2.2) + [u"re d"]=> + unicode(5) "color" + [u" Hello"]=> + int(111) +} +-- Iteration 9 -- +- default argument - +array(2) { + [u"Hello world"]=> + unicode(6) "string" + [0]=> + unicode(5) "hello" +} +- $preserve keys = true - +array(2) { + [u"Hello world"]=> + unicode(6) "string" + [0]=> + unicode(5) "hello" +} +- $preserve_keys = false - +array(2) { + [u"Hello world"]=> + unicode(6) "string" + [0]=> + unicode(5) "hello" +} +-- Iteration 10 -- +- default argument - +array(1) { + [u""]=> + unicode(5) "hello" +} +- $preserve keys = true - +array(1) { + [u""]=> + unicode(5) "hello" +} +- $preserve_keys = false - +array(1) { + [u""]=> + unicode(5) "hello" +} +-- Iteration 11 -- +- default argument - +array(6) { + [u"Hello world"]=> + unicode(7) "heredoc" + [u""]=> + unicode(5) "unset" + [0]=> + unicode(5) "float" + [1]=> + unicode(3) "int" + [u"fruit"]=> + float(2.2) + [u"hello"]=> + int(1) +} +- $preserve keys = true - +array(6) { + [u"Hello world"]=> + unicode(7) "heredoc" + [u""]=> + unicode(5) "unset" + [444]=> + unicode(5) "float" + [133]=> + unicode(3) "int" + [u"fruit"]=> + float(2.2) + [u"hello"]=> + int(1) +} +- $preserve_keys = false - +array(6) { + [u"Hello world"]=> + unicode(7) "heredoc" + [u""]=> + unicode(5) "unset" + [0]=> + unicode(5) "float" + [1]=> + unicode(3) "int" + [u"fruit"]=> + float(2.2) + [u"hello"]=> + int(1) +} +Done diff --git a/ext/standard/tests/array/array_reverse_variation5.phpt b/ext/standard/tests/array/array_reverse_variation5.phpt new file mode 100644 index 0000000000..978940127a --- /dev/null +++ b/ext/standard/tests/array/array_reverse_variation5.phpt @@ -0,0 +1,711 @@ +--TEST-- +Test array_reverse() function : usage variations - assoc. array with diff. value for 'array' argument +--FILE-- + 0), + array("1" => 1), + array("one" => 1, 'two' => 2, "three" => 3, 4 => 4), + + // arrays with float values +/*5*/ array("float" => 2.3333), + array("f1" => 1.2, 'f2' => 3.33, 3 => 4.89999922839999, 'f4' => 33333333.333333), + + // arrays with string values + array(111 => "\tHello", "red" => "col\tor", 2 => "\v\fworld", 3.3 => "pen\n"), +/*8*/ array(111 => '\tHello', "red" => 'col\tor', 2 => '\v\fworld', 3.3 => 'pen\n'), + array(1 => "hello", "heredoc" => $heredoc), + + // array with object, unset variable and resource variable + array(11 => new classA(), "unset" => @$unset_var, "resource" => $fp), + + // array with mixed values +/*11*/ array(1 => 'hello', 2 => new classA(), 222 => "fruit", 'resource' => $fp, "int" => 133, "float" => 444.432, "unset" => @$unset_var, "heredoc" => $heredoc) +); + +// loop through the various elements of $arrays to test array_reverse() +$iterator = 1; +foreach($arrays as $array) { + echo "-- Iteration $iterator --\n"; + // with default argument + echo "- default argument -\n"; + var_dump( array_reverse($array) ); + // with $preserve_keys argument + echo "- \$preserve keys = true -\n"; + var_dump( array_reverse($array, true) ); + echo "- \$preserve_keys = false -\n"; + var_dump( array_reverse($array, false) ); + $iterator++; +}; + +// close the file resource used +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_reverse() : usage variations *** +-- Iteration 1 -- +- default argument - +array(0) { +} +- $preserve keys = true - +array(0) { +} +- $preserve_keys = false - +array(0) { +} +-- Iteration 2 -- +- default argument - +array(1) { + [0]=> + int(0) +} +- $preserve keys = true - +array(1) { + [0]=> + int(0) +} +- $preserve_keys = false - +array(1) { + [0]=> + int(0) +} +-- Iteration 3 -- +- default argument - +array(1) { + [0]=> + int(1) +} +- $preserve keys = true - +array(1) { + [1]=> + int(1) +} +- $preserve_keys = false - +array(1) { + [0]=> + int(1) +} +-- Iteration 4 -- +- default argument - +array(4) { + [0]=> + int(4) + ["three"]=> + int(3) + ["two"]=> + int(2) + ["one"]=> + int(1) +} +- $preserve keys = true - +array(4) { + [4]=> + int(4) + ["three"]=> + int(3) + ["two"]=> + int(2) + ["one"]=> + int(1) +} +- $preserve_keys = false - +array(4) { + [0]=> + int(4) + ["three"]=> + int(3) + ["two"]=> + int(2) + ["one"]=> + int(1) +} +-- Iteration 5 -- +- default argument - +array(1) { + ["float"]=> + float(2.3333) +} +- $preserve keys = true - +array(1) { + ["float"]=> + float(2.3333) +} +- $preserve_keys = false - +array(1) { + ["float"]=> + float(2.3333) +} +-- Iteration 6 -- +- default argument - +array(4) { + ["f4"]=> + float(33333333.333333) + [0]=> + float(4.8999992284) + ["f2"]=> + float(3.33) + ["f1"]=> + float(1.2) +} +- $preserve keys = true - +array(4) { + ["f4"]=> + float(33333333.333333) + [3]=> + float(4.8999992284) + ["f2"]=> + float(3.33) + ["f1"]=> + float(1.2) +} +- $preserve_keys = false - +array(4) { + ["f4"]=> + float(33333333.333333) + [0]=> + float(4.8999992284) + ["f2"]=> + float(3.33) + ["f1"]=> + float(1.2) +} +-- Iteration 7 -- +- default argument - +array(4) { + [0]=> + string(4) "pen +" + [1]=> + string(7) " world" + ["red"]=> + string(6) "col or" + [2]=> + string(6) " Hello" +} +- $preserve keys = true - +array(4) { + [3]=> + string(4) "pen +" + [2]=> + string(7) " world" + ["red"]=> + string(6) "col or" + [111]=> + string(6) " Hello" +} +- $preserve_keys = false - +array(4) { + [0]=> + string(4) "pen +" + [1]=> + string(7) " world" + ["red"]=> + string(6) "col or" + [2]=> + string(6) " Hello" +} +-- Iteration 8 -- +- default argument - +array(4) { + [0]=> + string(5) "pen\n" + [1]=> + string(9) "\v\fworld" + ["red"]=> + string(7) "col\tor" + [2]=> + string(7) "\tHello" +} +- $preserve keys = true - +array(4) { + [3]=> + string(5) "pen\n" + [2]=> + string(9) "\v\fworld" + ["red"]=> + string(7) "col\tor" + [111]=> + string(7) "\tHello" +} +- $preserve_keys = false - +array(4) { + [0]=> + string(5) "pen\n" + [1]=> + string(9) "\v\fworld" + ["red"]=> + string(7) "col\tor" + [2]=> + string(7) "\tHello" +} +-- Iteration 9 -- +- default argument - +array(2) { + ["heredoc"]=> + string(11) "Hello world" + [0]=> + string(5) "hello" +} +- $preserve keys = true - +array(2) { + ["heredoc"]=> + string(11) "Hello world" + [1]=> + string(5) "hello" +} +- $preserve_keys = false - +array(2) { + ["heredoc"]=> + string(11) "Hello world" + [0]=> + string(5) "hello" +} +-- Iteration 10 -- +- default argument - +array(3) { + ["resource"]=> + resource(%d) of type (stream) + ["unset"]=> + NULL + [0]=> + object(classA)#%d (0) { + } +} +- $preserve keys = true - +array(3) { + ["resource"]=> + resource(%d) of type (stream) + ["unset"]=> + NULL + [11]=> + object(classA)#%d (0) { + } +} +- $preserve_keys = false - +array(3) { + ["resource"]=> + resource(%d) of type (stream) + ["unset"]=> + NULL + [0]=> + object(classA)#%d (0) { + } +} +-- Iteration 11 -- +- default argument - +array(8) { + ["heredoc"]=> + string(11) "Hello world" + ["unset"]=> + NULL + ["float"]=> + float(444.432) + ["int"]=> + int(133) + ["resource"]=> + resource(%d) of type (stream) + [0]=> + string(5) "fruit" + [1]=> + object(classA)#%d (0) { + } + [2]=> + string(5) "hello" +} +- $preserve keys = true - +array(8) { + ["heredoc"]=> + string(11) "Hello world" + ["unset"]=> + NULL + ["float"]=> + float(444.432) + ["int"]=> + int(133) + ["resource"]=> + resource(%d) of type (stream) + [222]=> + string(5) "fruit" + [2]=> + object(classA)#%d (0) { + } + [1]=> + string(5) "hello" +} +- $preserve_keys = false - +array(8) { + ["heredoc"]=> + string(11) "Hello world" + ["unset"]=> + NULL + ["float"]=> + float(444.432) + ["int"]=> + int(133) + ["resource"]=> + resource(%d) of type (stream) + [0]=> + string(5) "fruit" + [1]=> + object(classA)#%d (0) { + } + [2]=> + string(5) "hello" +} +Done +--UEXPECTF-- +*** Testing array_reverse() : usage variations *** +-- Iteration 1 -- +- default argument - +array(0) { +} +- $preserve keys = true - +array(0) { +} +- $preserve_keys = false - +array(0) { +} +-- Iteration 2 -- +- default argument - +array(1) { + [0]=> + int(0) +} +- $preserve keys = true - +array(1) { + [0]=> + int(0) +} +- $preserve_keys = false - +array(1) { + [0]=> + int(0) +} +-- Iteration 3 -- +- default argument - +array(1) { + [0]=> + int(1) +} +- $preserve keys = true - +array(1) { + [1]=> + int(1) +} +- $preserve_keys = false - +array(1) { + [0]=> + int(1) +} +-- Iteration 4 -- +- default argument - +array(4) { + [0]=> + int(4) + [u"three"]=> + int(3) + [u"two"]=> + int(2) + [u"one"]=> + int(1) +} +- $preserve keys = true - +array(4) { + [4]=> + int(4) + [u"three"]=> + int(3) + [u"two"]=> + int(2) + [u"one"]=> + int(1) +} +- $preserve_keys = false - +array(4) { + [0]=> + int(4) + [u"three"]=> + int(3) + [u"two"]=> + int(2) + [u"one"]=> + int(1) +} +-- Iteration 5 -- +- default argument - +array(1) { + [u"float"]=> + float(2.3333) +} +- $preserve keys = true - +array(1) { + [u"float"]=> + float(2.3333) +} +- $preserve_keys = false - +array(1) { + [u"float"]=> + float(2.3333) +} +-- Iteration 6 -- +- default argument - +array(4) { + [u"f4"]=> + float(33333333.333333) + [0]=> + float(4.8999992284) + [u"f2"]=> + float(3.33) + [u"f1"]=> + float(1.2) +} +- $preserve keys = true - +array(4) { + [u"f4"]=> + float(33333333.333333) + [3]=> + float(4.8999992284) + [u"f2"]=> + float(3.33) + [u"f1"]=> + float(1.2) +} +- $preserve_keys = false - +array(4) { + [u"f4"]=> + float(33333333.333333) + [0]=> + float(4.8999992284) + [u"f2"]=> + float(3.33) + [u"f1"]=> + float(1.2) +} +-- Iteration 7 -- +- default argument - +array(4) { + [0]=> + unicode(4) "pen +" + [1]=> + unicode(7) " world" + [u"red"]=> + unicode(6) "col or" + [2]=> + unicode(6) " Hello" +} +- $preserve keys = true - +array(4) { + [3]=> + unicode(4) "pen +" + [2]=> + unicode(7) " world" + [u"red"]=> + unicode(6) "col or" + [111]=> + unicode(6) " Hello" +} +- $preserve_keys = false - +array(4) { + [0]=> + unicode(4) "pen +" + [1]=> + unicode(7) " world" + [u"red"]=> + unicode(6) "col or" + [2]=> + unicode(6) " Hello" +} +-- Iteration 8 -- +- default argument - +array(4) { + [0]=> + unicode(5) "pen\n" + [1]=> + unicode(9) "\v\fworld" + [u"red"]=> + unicode(7) "col\tor" + [2]=> + unicode(7) "\tHello" +} +- $preserve keys = true - +array(4) { + [3]=> + unicode(5) "pen\n" + [2]=> + unicode(9) "\v\fworld" + [u"red"]=> + unicode(7) "col\tor" + [111]=> + unicode(7) "\tHello" +} +- $preserve_keys = false - +array(4) { + [0]=> + unicode(5) "pen\n" + [1]=> + unicode(9) "\v\fworld" + [u"red"]=> + unicode(7) "col\tor" + [2]=> + unicode(7) "\tHello" +} +-- Iteration 9 -- +- default argument - +array(2) { + [u"heredoc"]=> + unicode(11) "Hello world" + [0]=> + unicode(5) "hello" +} +- $preserve keys = true - +array(2) { + [u"heredoc"]=> + unicode(11) "Hello world" + [1]=> + unicode(5) "hello" +} +- $preserve_keys = false - +array(2) { + [u"heredoc"]=> + unicode(11) "Hello world" + [0]=> + unicode(5) "hello" +} +-- Iteration 10 -- +- default argument - +array(3) { + [u"resource"]=> + resource(%d) of type (stream) + [u"unset"]=> + NULL + [0]=> + object(classA)#%d (0) { + } +} +- $preserve keys = true - +array(3) { + [u"resource"]=> + resource(%d) of type (stream) + [u"unset"]=> + NULL + [11]=> + object(classA)#%d (0) { + } +} +- $preserve_keys = false - +array(3) { + [u"resource"]=> + resource(%d) of type (stream) + [u"unset"]=> + NULL + [0]=> + object(classA)#%d (0) { + } +} +-- Iteration 11 -- +- default argument - +array(8) { + [u"heredoc"]=> + unicode(11) "Hello world" + [u"unset"]=> + NULL + [u"float"]=> + float(444.432) + [u"int"]=> + int(133) + [u"resource"]=> + resource(%d) of type (stream) + [0]=> + unicode(5) "fruit" + [1]=> + object(classA)#%d (0) { + } + [2]=> + unicode(5) "hello" +} +- $preserve keys = true - +array(8) { + [u"heredoc"]=> + unicode(11) "Hello world" + [u"unset"]=> + NULL + [u"float"]=> + float(444.432) + [u"int"]=> + int(133) + [u"resource"]=> + resource(%d) of type (stream) + [222]=> + unicode(5) "fruit" + [2]=> + object(classA)#%d (0) { + } + [1]=> + unicode(5) "hello" +} +- $preserve_keys = false - +array(8) { + [u"heredoc"]=> + unicode(11) "Hello world" + [u"unset"]=> + NULL + [u"float"]=> + float(444.432) + [u"int"]=> + int(133) + [u"resource"]=> + resource(%d) of type (stream) + [0]=> + unicode(5) "fruit" + [1]=> + object(classA)#%d (0) { + } + [2]=> + unicode(5) "hello" +} +Done diff --git a/ext/standard/tests/array/array_reverse_variation6.phpt b/ext/standard/tests/array/array_reverse_variation6.phpt new file mode 100644 index 0000000000..4ea0c33b2c --- /dev/null +++ b/ext/standard/tests/array/array_reverse_variation6.phpt @@ -0,0 +1,373 @@ +--TEST-- +Test array_reverse() function : usage variations - two dimensional arrays for 'array' argument +--FILE-- + 'red', 'item' => 'pen', 'place' => 'LA'), + + // numeric array + array(1, 2, 3, 4, 5), + + // combination of numeric and associative arrays + array('a' => 'green', 'red', 'brown', 33, 88, 'orange', 'item' => 'ball') +); + +// calling array_reverse() with various types of 2-d arrays +// with default arguments +echo "-- with default argument --\n"; +var_dump( array_reverse($two_dimensional_array) ); // whole array +var_dump( array_reverse($two_dimensional_array[1]) ); // sub array + +// with $preserve_keys argument +echo "-- with all possible arguments --\n"; +// whole array +var_dump( array_reverse($two_dimensional_array, true) ); +var_dump( array_reverse($two_dimensional_array, false) ); +// sub array +var_dump( array_reverse($two_dimensional_array[1], true) ); +var_dump( array_reverse($two_dimensional_array[1], false) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_reverse() : usage variations *** +-- with default argument -- +array(3) { + [0]=> + array(7) { + ["a"]=> + string(5) "green" + [0]=> + string(3) "red" + [1]=> + string(5) "brown" + [2]=> + int(33) + [3]=> + int(88) + [4]=> + string(6) "orange" + ["item"]=> + string(4) "ball" + } + [1]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + [2]=> + array(3) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + ["place"]=> + string(2) "LA" + } +} +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +-- with all possible arguments -- +array(3) { + [2]=> + array(7) { + ["a"]=> + string(5) "green" + [0]=> + string(3) "red" + [1]=> + string(5) "brown" + [2]=> + int(33) + [3]=> + int(88) + [4]=> + string(6) "orange" + ["item"]=> + string(4) "ball" + } + [1]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + [0]=> + array(3) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + ["place"]=> + string(2) "LA" + } +} +array(3) { + [0]=> + array(7) { + ["a"]=> + string(5) "green" + [0]=> + string(3) "red" + [1]=> + string(5) "brown" + [2]=> + int(33) + [3]=> + int(88) + [4]=> + string(6) "orange" + ["item"]=> + string(4) "ball" + } + [1]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + [2]=> + array(3) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + ["place"]=> + string(2) "LA" + } +} +array(5) { + [4]=> + int(5) + [3]=> + int(4) + [2]=> + int(3) + [1]=> + int(2) + [0]=> + int(1) +} +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +Done +--UEXPECTF-- +*** Testing array_reverse() : usage variations *** +-- with default argument -- +array(3) { + [0]=> + array(7) { + [u"a"]=> + unicode(5) "green" + [0]=> + unicode(3) "red" + [1]=> + unicode(5) "brown" + [2]=> + int(33) + [3]=> + int(88) + [4]=> + unicode(6) "orange" + [u"item"]=> + unicode(4) "ball" + } + [1]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + [2]=> + array(3) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + [u"place"]=> + unicode(2) "LA" + } +} +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +-- with all possible arguments -- +array(3) { + [2]=> + array(7) { + [u"a"]=> + unicode(5) "green" + [0]=> + unicode(3) "red" + [1]=> + unicode(5) "brown" + [2]=> + int(33) + [3]=> + int(88) + [4]=> + unicode(6) "orange" + [u"item"]=> + unicode(4) "ball" + } + [1]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + [0]=> + array(3) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + [u"place"]=> + unicode(2) "LA" + } +} +array(3) { + [0]=> + array(7) { + [u"a"]=> + unicode(5) "green" + [0]=> + unicode(3) "red" + [1]=> + unicode(5) "brown" + [2]=> + int(33) + [3]=> + int(88) + [4]=> + unicode(6) "orange" + [u"item"]=> + unicode(4) "ball" + } + [1]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + [2]=> + array(3) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + [u"place"]=> + unicode(2) "LA" + } +} +array(5) { + [4]=> + int(5) + [3]=> + int(4) + [2]=> + int(3) + [1]=> + int(2) + [0]=> + int(1) +} +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +Done -- 2.50.1