]> granicus.if.org Git - php/commitdiff
New testcases for array_reverse() function
authorRaghubansh Kumar <kraghuba@php.net>
Mon, 15 Oct 2007 06:09:27 +0000 (06:09 +0000)
committerRaghubansh Kumar <kraghuba@php.net>
Mon, 15 Oct 2007 06:09:27 +0000 (06:09 +0000)
ext/standard/tests/array/array_reverse_basic1.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_basic2.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_error.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_variation1.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_variation2.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_variation3.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_variation4.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_variation5.phpt [new file with mode: 0644]
ext/standard/tests/array/array_reverse_variation6.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/array/array_reverse_basic1.phpt b/ext/standard/tests/array/array_reverse_basic1.phpt
new file mode 100644 (file)
index 0000000..f41e0a3
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+Test array_reverse() function : basic functionality - simple array for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing array_reverse() by giving a simple array for $array argument 
+*/
+
+echo "*** Testing array_reverse() : basic functionality ***\n";
+
+// Initialise the array
+$array = array("a", "green", "red", '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(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
diff --git a/ext/standard/tests/array/array_reverse_basic2.phpt b/ext/standard/tests/array/array_reverse_basic2.phpt
new file mode 100644 (file)
index 0000000..9f41f0b
--- /dev/null
@@ -0,0 +1,60 @@
+--TEST--
+Test array_reverse() function : basic functionality - associative array for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed 
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing array_reverse() with associative array for $array argument
+*/
+
+echo "*** Testing array_reverse() : basic functionality ***\n";
+
+// Initialise the array
+$array = array("a" => "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
diff --git a/ext/standard/tests/array/array_reverse_error.phpt b/ext/standard/tests/array/array_reverse_error.phpt
new file mode 100644 (file)
index 0000000..8ec42bf
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Test array_reverse() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed 
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing array_reverse() : error conditions ***\n";
+
+// zero arguments
+echo "\n-- Testing array_reverse() function with Zero arguments --\n";
+var_dump( array_reverse() );
+
+// more than the expected number of arguments
+echo "\n-- Testing array_diff() function with more than expected no. of arguments --\n";
+$array = array(1, 2, 3, 4, 5, 6);
+$extra_arg = 10;
+var_dump( array_reverse($array, true, $extra_arg) );
+var_dump( array_reverse($array, false, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_reverse() : error conditions ***
+
+-- Testing array_reverse() function with Zero arguments --
+
+Warning: Wrong parameter count for array_reverse() in %s on line %d
+NULL
+
+-- Testing array_diff() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for array_reverse() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for array_reverse() in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/array/array_reverse_variation1.phpt b/ext/standard/tests/array/array_reverse_variation1.phpt
new file mode 100644 (file)
index 0000000..ea0c222
--- /dev/null
@@ -0,0 +1,340 @@
+--TEST--
+Test array_reverse() function : usage variations - unexpected values for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing array_reverse() : usage variations - unexpected values for 'array' argument ***\n";
+
+//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";
+  }
+}
+
+//get a heredoc string
+$heredoc_string = <<<EOT
+Hello world\t\n
+EOT;
+
+//array of values to iterate over
+$arrays = array (
+
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       10.5e10,
+       10.6E-10,
+       .5,
+
+       // null data
+/*10*/ NULL,
+       null,
+
+       // boolean data
+       true,
+       false,
+       TRUE,
+       FALSE,
+
+       // empty data
+/*16*/ "",
+       '',
+      
+       // string data
+       'Hello world',
+       "Hello world",
+       $heredoc_string,
+  
+       // object data
+/*21*/ new classA(),
+
+       // undefined data
+       @$undefined_var,
+
+       // unset data
+       @$unset_var,
+
+       // resource variable
+/*24*/ $fp
+
+);
+
+// loop through each element of the array $arrays to check the behavior of array_reverse()
+$iterator = 1;
+foreach($arrays as $array) {
+  echo "\n-- Iteration $iterator --";
+  // with default argument
+  var_dump( array_reverse($array) );
+  // with all possible arguments
+  var_dump( array_reverse($array, true) );
+  var_dump( array_reverse($array, false) );
+  $iterator++;
+};
+
+// close the file resource used
+fclose($fp);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_reverse() : usage variations - unexpected values for 'array' argument ***
+
+-- Iteration 1 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 2 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 3 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 4 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 5 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 6 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 7 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 8 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 9 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 10 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 11 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 12 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 13 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 14 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 15 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 16 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 17 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 18 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 19 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 20 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 21 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 22 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 23 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+-- Iteration 24 --
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array in %s on line %d
+NULL
+
+Warning: array_reverse(): The argument should be an array 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 (file)
index 0000000..1f036a3
--- /dev/null
@@ -0,0 +1,491 @@
+--TEST--
+Test array_reverse() function : usage variations - unexpected values for 'preserve_keys' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * testing the functionality of array_reverse() by giving unexpected values for $preserve_keys argument
+*/
+
+echo "*** Testing array_reverse() : usage variations ***\n";
+
+// Initialise the array
+$array = array("a" => "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 --
+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 11 --
+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 12 --
+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 13 --
+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 14 --
+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 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 --
+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 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 --
+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"
+}
+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 (file)
index 0000000..1029842
--- /dev/null
@@ -0,0 +1,602 @@
+--TEST--
+Test array_reverse() function : usage variations - different array values for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_reverse() by giving
+ * different array values for $array argument
+*/
+
+echo "*** Testing array_reverse() : usage variations ***\n";
+
+//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";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+$arrays = array (
+/*1*/  array(1, 2), // array with default keys and numeric values
+       array(1.1, 2.2), // array with default keys & float values
+       array( array(2), array(1)), // sub arrays
+       array(false,true), // array with default keys and boolean values
+       array(), // empty array
+       array(NULL), // array with NULL
+       array("a","aaaa","b","bbbb","c","ccccc"),
+
+       // associative arrays
+/*8*/  array(1 => "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
diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt
new file mode 100644 (file)
index 0000000..e3f0254
--- /dev/null
@@ -0,0 +1,377 @@
+--TEST--
+Test array_reverse() function : usage variations - assoc. array with diff. keys for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_reverse() by giving associative arrays with different
+ * keys for $array argument
+*/
+
+echo "*** Testing array_reverse() : usage variations ***\n";
+
+//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";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+// initializing the array
+$arrays = array (
+
+       // empty array
+/*1*/  array(),
+
+       // arrays with integer keys
+       array(0 => "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)
+  ["\v\fworld"]=>
+  float(2.2)
+  ["re d"]=>
+  string(5) "color"
+  ["   Hello"]=>
+  int(111)
+}
+- $preserve keys = true -
+array(4) {
+  ["pen
+"]=>
+  int(33)
+  ["\v\fworld"]=>
+  float(2.2)
+  ["re d"]=>
+  string(5) "color"
+  ["   Hello"]=>
+  int(111)
+}
+- $preserve_keys = false -
+array(4) {
+  ["pen
+"]=>
+  int(33)
+  ["\v\fworld"]=>
+  float(2.2)
+  ["re d"]=>
+  string(5) "color"
+  ["   Hello"]=>
+  int(111)
+}
+-- Iteration 8 --
+- default argument -
+array(4) {
+  ["pen
+"]=>
+  int(33)
+  ["\v\fworld"]=>
+  float(2.2)
+  ["re d"]=>
+  string(5) "color"
+  ["   Hello"]=>
+  int(111)
+}
+- $preserve keys = true -
+array(4) {
+  ["pen
+"]=>
+  int(33)
+  ["\v\fworld"]=>
+  float(2.2)
+  ["re d"]=>
+  string(5) "color"
+  ["   Hello"]=>
+  int(111)
+}
+- $preserve_keys = false -
+array(4) {
+  ["pen
+"]=>
+  int(33)
+  ["\v\fworld"]=>
+  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
diff --git a/ext/standard/tests/array/array_reverse_variation5.phpt b/ext/standard/tests/array/array_reverse_variation5.phpt
new file mode 100644 (file)
index 0000000..2d22be0
--- /dev/null
@@ -0,0 +1,397 @@
+--TEST--
+Test array_reverse() function : usage variations - assoc. array with diff. value for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing the functionality of array_reverse() by giving associative arrays with different
+ * values for $array argument
+*/
+
+echo "*** Testing array_reverse() : usage variations ***\n";
+
+//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";
+  }
+}
+
+// get a heredoc string
+$heredoc = <<<EOT
+Hello world
+EOT;
+
+// initializing the array
+$arrays = array (
+
+       // empty array
+/*1*/  array(),
+
+       // arrays with integer values
+       array('0' => 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) "\v\fworld"
+  ["red"]=>
+  string(6) "col       or"
+  [2]=>
+  string(6) "  Hello"
+}
+- $preserve keys = true -
+array(4) {
+  [3]=>
+  string(4) "pen
+"
+  [2]=>
+  string(7) "\v\fworld"
+  ["red"]=>
+  string(6) "col       or"
+  [111]=>
+  string(6) "  Hello"
+}
+- $preserve_keys = false -
+array(4) {
+  [0]=>
+  string(4) "pen
+"
+  [1]=>
+  string(7) "\v\fworld"
+  ["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
diff --git a/ext/standard/tests/array/array_reverse_variation6.phpt b/ext/standard/tests/array/array_reverse_variation6.phpt
new file mode 100644 (file)
index 0000000..ae1e195
--- /dev/null
@@ -0,0 +1,209 @@
+--TEST--
+Test array_reverse() function : usage variations - two dimensional arrays for 'array' argument
+--FILE--
+<?php
+/* Prototype  : array array_reverse(array $array [, bool $preserve_keys])
+ * Description: Return input as a new array with the order of the entries reversed
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * testing the functionality of array_reverse() by giving 2-D arrays for $array argument
+*/
+
+echo "*** Testing array_reverse() : usage variations ***\n";
+
+// Initializing the 2-d arrays
+$two_dimensional_array = array(
+     
+  // associative array
+  array('color' => '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