]> granicus.if.org Git - php/commitdiff
- New tests for rsort() function
authorJosie Messa <jmessa@php.net>
Fri, 15 Feb 2008 16:05:28 +0000 (16:05 +0000)
committerJosie Messa <jmessa@php.net>
Fri, 15 Feb 2008 16:05:28 +0000 (16:05 +0000)
15 files changed:
ext/standard/tests/array/rsort_basic.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_error.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_object1.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_object2.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation1.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation10.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation11.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation2.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation3.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation4.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation5.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation6.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation7.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation8.phpt [new file with mode: 0644]
ext/standard/tests/array/rsort_variation9.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/array/rsort_basic.phpt b/ext/standard/tests/array/rsort_basic.phpt
new file mode 100644 (file)
index 0000000..5495be9
--- /dev/null
@@ -0,0 +1,129 @@
+--TEST--
+Test rsort() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test basic functionality of rsort()
+ */
+
+echo "*** Testing rsort() : basic functionality ***\n";
+
+// associative array containing unsorted string values  
+$unsorted_strings =   array( "l" => "lemon", "o" => "orange", "b" => "banana" );
+// array with default keys containing unsorted numeric values
+$unsorted_numerics =  array( 100, 33, 555, 22 );
+
+echo "\n-- Testing rsort() by supplying string array, 'flag' value is defualt --\n";
+$temp_array = $unsorted_strings;
+var_dump( rsort($temp_array) );
+var_dump( $temp_array);
+
+echo "\n-- Testing rsort() by supplying numeric array, 'flag' value is defualt --\n";
+$temp_array = $unsorted_numerics;
+var_dump( rsort($temp_array) );
+var_dump( $temp_array);
+
+echo "\n-- Testing rsort() by supplying string array, 'flag' = SORT_REGULAR --\n";
+$temp_array = $unsorted_strings;
+var_dump( rsort($temp_array, SORT_REGULAR) );
+var_dump( $temp_array);
+
+echo "\n-- Testing rsort() by supplying numeric array, 'flag' = SORT_REGULAR --\n";
+$temp_array = $unsorted_numerics;
+var_dump( rsort($temp_array, SORT_REGULAR) );
+var_dump( $temp_array);
+
+echo "\n-- Testing rsort() by supplying string array, 'flag' = SORT_STRING --\n";
+$temp_array = $unsorted_strings;
+var_dump( rsort($temp_array, SORT_STRING) );
+var_dump( $temp_array);
+
+echo "\n-- Testing rsort() by supplying numeric array, 'flag' = SORT_NUMERIC --\n";
+$temp_array = $unsorted_numerics;
+var_dump( rsort($temp_array, SORT_NUMERIC) );
+var_dump( $temp_array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : basic functionality ***
+
+-- Testing rsort() by supplying string array, 'flag' value is defualt --
+bool(true)
+array(3) {
+  [0]=>
+  string(6) "orange"
+  [1]=>
+  string(5) "lemon"
+  [2]=>
+  string(6) "banana"
+}
+
+-- Testing rsort() by supplying numeric array, 'flag' value is defualt --
+bool(true)
+array(4) {
+  [0]=>
+  int(555)
+  [1]=>
+  int(100)
+  [2]=>
+  int(33)
+  [3]=>
+  int(22)
+}
+
+-- Testing rsort() by supplying string array, 'flag' = SORT_REGULAR --
+bool(true)
+array(3) {
+  [0]=>
+  string(6) "orange"
+  [1]=>
+  string(5) "lemon"
+  [2]=>
+  string(6) "banana"
+}
+
+-- Testing rsort() by supplying numeric array, 'flag' = SORT_REGULAR --
+bool(true)
+array(4) {
+  [0]=>
+  int(555)
+  [1]=>
+  int(100)
+  [2]=>
+  int(33)
+  [3]=>
+  int(22)
+}
+
+-- Testing rsort() by supplying string array, 'flag' = SORT_STRING --
+bool(true)
+array(3) {
+  [0]=>
+  string(6) "orange"
+  [1]=>
+  string(5) "lemon"
+  [2]=>
+  string(6) "banana"
+}
+
+-- Testing rsort() by supplying numeric array, 'flag' = SORT_NUMERIC --
+bool(true)
+array(4) {
+  [0]=>
+  int(555)
+  [1]=>
+  int(100)
+  [2]=>
+  int(33)
+  [3]=>
+  int(22)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_error.phpt b/ext/standard/tests/array/rsort_error.phpt
new file mode 100644 (file)
index 0000000..6f6f2f9
--- /dev/null
@@ -0,0 +1,51 @@
+--TEST--
+Test rsort() function : error conditions - Pass incorrect number of args
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass incorrect number of arguments to rsort() to test behaviour
+ */
+
+echo "*** Testing rsort() : error conditions ***\n";
+
+// zero arguments
+echo "\n-- Testing rsort() function with Zero arguments --\n";
+var_dump( rsort() );
+
+//Test rsort() with more than the expected number of arguments
+echo "\n-- Testing rsort() function with more than expected no. of arguments --\n";
+$array_arg = array(1, 2);
+$sort_flags = SORT_REGULAR;
+$extra_arg = 10;
+var_dump( rsort($array_arg, $sort_flags, $extra_arg) );
+
+// dump the input array to ensure that it wasn't changed
+var_dump($array_arg);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : error conditions ***
+
+-- Testing rsort() function with Zero arguments --
+
+Warning: rsort() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+-- Testing rsort() function with more than expected no. of arguments --
+
+Warning: rsort() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+array(2) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_object1.phpt b/ext/standard/tests/array/rsort_object1.phpt
new file mode 100644 (file)
index 0000000..98f7cfe
--- /dev/null
@@ -0,0 +1,243 @@
+--TEST--
+Test rsort() function : object functionality
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test basic functionality of rsort() with objects
+ */
+
+echo "*** Testing rsort() : object functionality ***\n";
+
+// class declaration for integer objects
+class for_integer_rsort
+{
+       public $class_value;
+       // initializing object member value
+       function __construct($value){
+               $this->class_value = $value;
+       }
+
+}
+
+// class declaration for string objects
+class for_string_rsort
+{
+       public $class_value;
+       // initializing object member value
+       function __construct($value){
+               $this->class_value = $value;
+       }
+
+       // return string value
+       function __tostring() {
+               return (string)$this->value;
+       }
+
+}
+
+// array of integer objects
+$unsorted_int_obj = array( 
+  new for_integer_rsort(11), new for_integer_rsort(66),
+  new for_integer_rsort(23), new for_integer_rsort(-5),
+  new for_integer_rsort(0.001), new for_integer_rsort(0)
+);
+
+// array of string objects
+$unsorted_str_obj = array ( 
+  new for_string_rsort("axx"), new for_string_rsort("t"),
+  new for_string_rsort("w"), new for_string_rsort("py"),
+  new for_string_rsort("apple"), new for_string_rsort("Orange"),
+  new for_string_rsort("Lemon"), new for_string_rsort("aPPle")
+);
+
+
+echo "\n-- Sort flag = default --\n";
+
+// testing rsort() function by supplying integer object array, flag value is defualt
+$temp_array = $unsorted_int_obj;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+// testing rsort() function by supplying string object array, flag value is defualt
+$temp_array = $unsorted_str_obj;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+echo "\n-- Sort flag = SORT_REGULAR --\n";
+// testing rsort() function by supplying integer object array, flag value = SORT_REGULAR
+$temp_array = $unsorted_int_obj;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+// testing rsort() function by supplying string object array, flag value = SORT_REGULAR
+$temp_array = $unsorted_str_obj;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : object functionality ***
+
+-- Sort flag = default --
+bool(true)
+array(6) {
+  [0]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(66)
+  }
+  [1]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(23)
+  }
+  [2]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(11)
+  }
+  [3]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    float(0.001)
+  }
+  [4]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(0)
+  }
+  [5]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(-5)
+  }
+}
+bool(true)
+array(8) {
+  [0]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(1) "w"
+  }
+  [1]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(1) "t"
+  }
+  [2]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(2) "py"
+  }
+  [3]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(3) "axx"
+  }
+  [4]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(5) "apple"
+  }
+  [5]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(5) "aPPle"
+  }
+  [6]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(6) "Orange"
+  }
+  [7]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(5) "Lemon"
+  }
+}
+
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(6) {
+  [0]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(66)
+  }
+  [1]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(23)
+  }
+  [2]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(11)
+  }
+  [3]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    float(0.001)
+  }
+  [4]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(0)
+  }
+  [5]=>
+  object(for_integer_rsort)#%d (1) {
+    ["class_value"]=>
+    int(-5)
+  }
+}
+bool(true)
+array(8) {
+  [0]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(1) "w"
+  }
+  [1]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(1) "t"
+  }
+  [2]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(2) "py"
+  }
+  [3]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(3) "axx"
+  }
+  [4]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(5) "apple"
+  }
+  [5]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(5) "aPPle"
+  }
+  [6]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(6) "Orange"
+  }
+  [7]=>
+  object(for_string_rsort)#%d (1) {
+    ["class_value"]=>
+    string(5) "Lemon"
+  }
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_object2.phpt b/ext/standard/tests/array/rsort_object2.phpt
new file mode 100644 (file)
index 0000000..216d3c9
--- /dev/null
@@ -0,0 +1,258 @@
+--TEST--
+Test rsort() function : object functionality - different visibilities
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test functionality of rsort() with objects where properties have different visibilities
+ */
+
+echo "*** Testing rsort() : object functionality ***\n";
+
+// class declaration for integer objects
+class for_integer_rsort
+{
+       public $public_class_value;
+       private $private_class_value;
+       protected $protected_class_value;
+
+       // initializing object member value
+       function __construct($value1, $value2,$value3){
+               $this->public_class_value = $value1;
+               $this->private_class_value = $value2;
+               $this->protected_class_value = $value3;
+       }
+
+}
+
+// class declaration for string objects
+class for_string_rsort
+{
+       public $public_class_value;
+       private $private_class_value;
+       protected $protected_class_value;
+       // initializing object member value
+       function __construct($value1, $value2,$value3){
+               $this->public_class_value = $value1;
+               $this->private_class_value = $value2;
+               $this->protected_class_value = $value3;
+       }
+
+       // return string value
+       function __tostring() {
+               return (string)$this->value;
+       }
+
+}
+
+// array of integer objects
+
+$unsorted_int_obj = array( 
+  new for_integer_rsort(11,33,30),
+  new for_integer_rsort(66,44,4),
+  new for_integer_rsort(-88,-5,5),
+  new for_integer_rsort(0.001,99.5,0.1)
+);
+
+// array of string objects
+$unsorted_str_obj = array ( 
+  new for_string_rsort("axx","AXX","ass"), 
+  new for_string_rsort("t","eee","abb"),
+  new for_string_rsort("w","W", "c"),
+  new for_string_rsort("py","PY", "pt"),
+);
+
+
+echo "\n-- Sort flag = default --\n";
+
+// testing rsort() function by supplying integer object array, flag value is defualt
+$temp_array = $unsorted_int_obj;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+// testing rsort() function by supplying string object array, flag value is defualt
+$temp_array = $unsorted_str_obj;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+echo "\n-- Sort flag = SORT_REGULAR --\n";
+// testing rsort() function by supplying integer object array, flag value = SORT_REGULAR
+$temp_array = $unsorted_int_obj;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+// testing rsort() function by supplying string object array, flag value = SORT_REGULAR
+$temp_array = $unsorted_str_obj;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : object functionality ***
+
+-- Sort flag = default --
+bool(true)
+array(4) {
+  [0]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    int(66)
+    ["private_class_value:private"]=>
+    int(44)
+    ["protected_class_value:protected"]=>
+    int(4)
+  }
+  [1]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    int(11)
+    ["private_class_value:private"]=>
+    int(33)
+    ["protected_class_value:protected"]=>
+    int(30)
+  }
+  [2]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    float(0.001)
+    ["private_class_value:private"]=>
+    float(99.5)
+    ["protected_class_value:protected"]=>
+    float(0.1)
+  }
+  [3]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    int(-88)
+    ["private_class_value:private"]=>
+    int(-5)
+    ["protected_class_value:protected"]=>
+    int(5)
+  }
+}
+bool(true)
+array(4) {
+  [0]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(1) "w"
+    ["private_class_value:private"]=>
+    string(1) "W"
+    ["protected_class_value:protected"]=>
+    string(1) "c"
+  }
+  [1]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(1) "t"
+    ["private_class_value:private"]=>
+    string(3) "eee"
+    ["protected_class_value:protected"]=>
+    string(3) "abb"
+  }
+  [2]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(2) "py"
+    ["private_class_value:private"]=>
+    string(2) "PY"
+    ["protected_class_value:protected"]=>
+    string(2) "pt"
+  }
+  [3]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(3) "axx"
+    ["private_class_value:private"]=>
+    string(3) "AXX"
+    ["protected_class_value:protected"]=>
+    string(3) "ass"
+  }
+}
+
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(4) {
+  [0]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    int(66)
+    ["private_class_value:private"]=>
+    int(44)
+    ["protected_class_value:protected"]=>
+    int(4)
+  }
+  [1]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    int(11)
+    ["private_class_value:private"]=>
+    int(33)
+    ["protected_class_value:protected"]=>
+    int(30)
+  }
+  [2]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    float(0.001)
+    ["private_class_value:private"]=>
+    float(99.5)
+    ["protected_class_value:protected"]=>
+    float(0.1)
+  }
+  [3]=>
+  object(for_integer_rsort)#%d (3) {
+    ["public_class_value"]=>
+    int(-88)
+    ["private_class_value:private"]=>
+    int(-5)
+    ["protected_class_value:protected"]=>
+    int(5)
+  }
+}
+bool(true)
+array(4) {
+  [0]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(1) "w"
+    ["private_class_value:private"]=>
+    string(1) "W"
+    ["protected_class_value:protected"]=>
+    string(1) "c"
+  }
+  [1]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(1) "t"
+    ["private_class_value:private"]=>
+    string(3) "eee"
+    ["protected_class_value:protected"]=>
+    string(3) "abb"
+  }
+  [2]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(2) "py"
+    ["private_class_value:private"]=>
+    string(2) "PY"
+    ["protected_class_value:protected"]=>
+    string(2) "pt"
+  }
+  [3]=>
+  object(for_string_rsort)#%d (3) {
+    ["public_class_value"]=>
+    string(3) "axx"
+    ["private_class_value:private"]=>
+    string(3) "AXX"
+    ["protected_class_value:protected"]=>
+    string(3) "ass"
+  }
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation1.phpt b/ext/standard/tests/array/rsort_variation1.phpt
new file mode 100644 (file)
index 0000000..96dac90
--- /dev/null
@@ -0,0 +1,514 @@
+--TEST--
+Test rsort() function : usage variations - Pass different data types as $array_arg arg
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass different data types as $array_arg argument to rsort() to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA
+{
+  public function __toString() {
+    return "Class A object";
+  }
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $array_arg argument
+$inputs = array(
+
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*10*/ NULL,
+       null,
+
+       // boolean data
+/*12*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*16*/ "",
+       '',
+
+       // string data
+/*18*/ "string",
+       'string',
+       $heredoc,
+       
+       // object data
+/*21*/ new classA(),
+
+       // undefined data
+/*22*/ @$undefined_var,
+
+       // unset data
+/*23*/ @$unset_var,
+
+       // resource variable
+/*24*/ $fp
+);
+
+// loop through each element of $inputs to check the behavior of rsort()
+$iterator = 1;
+foreach ($inputs as $input) {
+  echo "-- Iteration $iterator --\n";
+  echo "Flag = default:\n";
+  var_dump( rsort($input) );
+  echo "Flag = SORT_REGULAR:\n";
+  var_dump( rsort($input, SORT_REGULAR) );
+  echo "Flag = SORT_NUMERIC:\n";
+  var_dump( rsort($input, SORT_NUMERIC) );
+  echo "Flag = SORT_STRING:\n";
+  var_dump( rsort($input, SORT_STRING) );
+  $iterator++;
+}
+
+fclose($fp);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+-- Iteration 1 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+-- Iteration 2 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+-- Iteration 4 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d
+bool(false)
+-- Iteration 5 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+-- Iteration 6 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+-- Iteration 7 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+-- Iteration 8 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+-- Iteration 9 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, double given in %s on line %d
+bool(false)
+-- Iteration 10 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+-- Iteration 11 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+-- Iteration 12 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+-- Iteration 13 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+-- Iteration 14 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+-- Iteration 15 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d
+bool(false)
+-- Iteration 16 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+-- Iteration 17 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+-- Iteration 18 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+-- Iteration 19 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+-- Iteration 20 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, string given in %s on line %d
+bool(false)
+-- Iteration 21 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, object given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, object given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, object given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, object given in %s on line %d
+bool(false)
+-- Iteration 22 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+-- Iteration 23 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, null given in %s on line %d
+bool(false)
+-- Iteration 24 --
+Flag = default:
+
+Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d
+bool(false)
+Flag = SORT_REGULAR:
+
+Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d
+bool(false)
+Flag = SORT_NUMERIC:
+
+Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d
+bool(false)
+Flag = SORT_STRING:
+
+Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d
+bool(false)
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation10.phpt b/ext/standard/tests/array/rsort_variation10.phpt
new file mode 100644 (file)
index 0000000..ccf886b
--- /dev/null
@@ -0,0 +1,108 @@
+--TEST--
+Test rsort() function : usage variations - Octal values
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass rsort() an array containing octal values to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// an array containing unsorted octal values
+$unsorted_oct_array = array(01235, 0321, 0345, 066, 0772, 077, -066, -0345, 0);
+
+echo "\n-- Sort flag = default  --\n";
+$temp_array = $unsorted_oct_array;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+echo "\n-- Sort flag = SORT_REGULAR  --\n";
+$temp_array = $unsorted_oct_array;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+echo "\n-- Sort flag = SORT_NUMERIC  --\n";
+$temp_array = $unsorted_oct_array;
+var_dump(rsort($temp_array, SORT_NUMERIC) );
+var_dump($temp_array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- Sort flag = default  --
+bool(true)
+array(9) {
+  [0]=>
+  int(669)
+  [1]=>
+  int(506)
+  [2]=>
+  int(229)
+  [3]=>
+  int(209)
+  [4]=>
+  int(63)
+  [5]=>
+  int(54)
+  [6]=>
+  int(0)
+  [7]=>
+  int(-54)
+  [8]=>
+  int(-229)
+}
+
+-- Sort flag = SORT_REGULAR  --
+bool(true)
+array(9) {
+  [0]=>
+  int(669)
+  [1]=>
+  int(506)
+  [2]=>
+  int(229)
+  [3]=>
+  int(209)
+  [4]=>
+  int(63)
+  [5]=>
+  int(54)
+  [6]=>
+  int(0)
+  [7]=>
+  int(-54)
+  [8]=>
+  int(-229)
+}
+
+-- Sort flag = SORT_NUMERIC  --
+bool(true)
+array(9) {
+  [0]=>
+  int(669)
+  [1]=>
+  int(506)
+  [2]=>
+  int(229)
+  [3]=>
+  int(209)
+  [4]=>
+  int(63)
+  [5]=>
+  int(54)
+  [6]=>
+  int(0)
+  [7]=>
+  int(-54)
+  [8]=>
+  int(-229)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation11.phpt b/ext/standard/tests/array/rsort_variation11.phpt
new file mode 100644 (file)
index 0000000..83bbf84
Binary files /dev/null and b/ext/standard/tests/array/rsort_variation11.phpt differ
diff --git a/ext/standard/tests/array/rsort_variation2.phpt b/ext/standard/tests/array/rsort_variation2.phpt
new file mode 100644 (file)
index 0000000..2196a64
--- /dev/null
@@ -0,0 +1,484 @@
+--TEST--
+Test rsort() function : usage variations - Pass different data types as $sort_flags arg
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass different data types as $sort_flags argument to rsort() to test behaviour
+ * Where possible, 'SORT_NUMERIC' has been entered as a string value
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// Initialise function arguments not being substituted
+$array_arg = array (1, 5, 2, 3, 1);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA
+{
+  public function __toString() {
+    return "SORT_NUMERIC";
+  }
+}
+
+// heredoc string
+$heredoc = <<<EOT
+SORT_NUMERIC
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $sort_flags argument
+$inputs = array(
+
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*10*/ NULL,
+       null,
+
+       // boolean data
+/*12*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*16*/ "",
+       '',
+
+       // string data
+/*18*/ "SORT_NUMERIC",
+       'SORT_NUMERIC',
+       $heredoc,
+       
+       // object data
+/*21*/ new classA(),
+
+       // undefined data
+/*22*/ @$undefined_var,
+
+       // unset data
+/*23*/ @$unset_var,
+
+       // resource variable
+/*24*/ $fp
+);
+
+// loop through each element of $inputs to check the behavior of rsort()
+$iterator = 1;
+foreach($inputs as $input) {
+  echo "\n-- Iteration $iterator --\n";
+  
+  //create temporary array in case rsort() works
+  $temp = $array_arg;
+  
+  var_dump( rsort($temp, $input) );
+  var_dump($temp);
+  $iterator++;
+  
+  $temp = null;
+};
+
+fclose($fp);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- Iteration 1 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 2 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 3 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 4 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 5 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 6 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 7 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 8 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 9 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 10 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 11 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 12 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 13 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 14 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 15 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 16 --
+
+Warning: rsort() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 17 --
+
+Warning: rsort() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 18 --
+
+Warning: rsort() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 19 --
+
+Warning: rsort() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 20 --
+
+Warning: rsort() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 21 --
+
+Warning: rsort() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 22 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 23 --
+bool(true)
+array(5) {
+  [0]=>
+  int(5)
+  [1]=>
+  int(3)
+  [2]=>
+  int(2)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+}
+
+-- Iteration 24 --
+
+Warning: rsort() expects parameter 2 to be long, resource given in %s on line %d
+bool(false)
+array(5) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(5)
+  [2]=>
+  int(2)
+  [3]=>
+  int(3)
+  [4]=>
+  int(1)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation3.phpt b/ext/standard/tests/array/rsort_variation3.phpt
new file mode 100644 (file)
index 0000000..c0c11b5
--- /dev/null
@@ -0,0 +1,321 @@
+--TEST--
+Test rsort() function : usage variations - numeric values
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass arrays containing different numeric data to rsort() to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// group of various arrays
+
+$various_arrays = array (
+// negative/positive integers array
+array(11, -11, 21, -21, 31, -31, 0, 41, -41),
+
+// float value array
+array(10.5, -10.5, 10.5e2, 10.6E-2, .5, .01, -.1),
+
+// mixed value array
+array(.0001, .0021, -.01, -1, 0, .09, 2, -.9, 10.6E-2, -10.6E-2, 33),
+
+// array values contains minimum and maximum ranges
+array(2147483647, 2147483648, -2147483647, -2147483648, -0, 0, -2147483649)
+);
+
+// set of possible flag values
+$flag_value = array("SORT_REGULAR" => SORT_REGULAR, "SORT_NUMERIC" => SORT_NUMERIC);
+
+$count = 1;
+
+// loop through to test rsort() with different arrays
+foreach ($various_arrays as $array) {
+  echo "\n-- Iteration $count --\n";
+
+  echo "- With Defualt sort flag -\n"; 
+  $temp_array = $array; 
+  var_dump(rsort($temp_array) );
+  var_dump($temp_array);
+
+  // loop through $flag_value array and setting all possible flag values
+  foreach($flag_value as $key => $flag){
+    echo "- Sort flag = $key -\n";
+    $temp_array = $array; 
+    var_dump(rsort($temp_array, $flag) );
+    var_dump($temp_array);
+  }  
+  $count++;
+} 
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- Iteration 1 --
+- With Defualt sort flag -
+bool(true)
+array(9) {
+  [0]=>
+  int(41)
+  [1]=>
+  int(31)
+  [2]=>
+  int(21)
+  [3]=>
+  int(11)
+  [4]=>
+  int(0)
+  [5]=>
+  int(-11)
+  [6]=>
+  int(-21)
+  [7]=>
+  int(-31)
+  [8]=>
+  int(-41)
+}
+- Sort flag = SORT_REGULAR -
+bool(true)
+array(9) {
+  [0]=>
+  int(41)
+  [1]=>
+  int(31)
+  [2]=>
+  int(21)
+  [3]=>
+  int(11)
+  [4]=>
+  int(0)
+  [5]=>
+  int(-11)
+  [6]=>
+  int(-21)
+  [7]=>
+  int(-31)
+  [8]=>
+  int(-41)
+}
+- Sort flag = SORT_NUMERIC -
+bool(true)
+array(9) {
+  [0]=>
+  int(41)
+  [1]=>
+  int(31)
+  [2]=>
+  int(21)
+  [3]=>
+  int(11)
+  [4]=>
+  int(0)
+  [5]=>
+  int(-11)
+  [6]=>
+  int(-21)
+  [7]=>
+  int(-31)
+  [8]=>
+  int(-41)
+}
+
+-- Iteration 2 --
+- With Defualt sort flag -
+bool(true)
+array(7) {
+  [0]=>
+  float(1050)
+  [1]=>
+  float(10.5)
+  [2]=>
+  float(0.5)
+  [3]=>
+  float(0.106)
+  [4]=>
+  float(0.01)
+  [5]=>
+  float(-0.1)
+  [6]=>
+  float(-10.5)
+}
+- Sort flag = SORT_REGULAR -
+bool(true)
+array(7) {
+  [0]=>
+  float(1050)
+  [1]=>
+  float(10.5)
+  [2]=>
+  float(0.5)
+  [3]=>
+  float(0.106)
+  [4]=>
+  float(0.01)
+  [5]=>
+  float(-0.1)
+  [6]=>
+  float(-10.5)
+}
+- Sort flag = SORT_NUMERIC -
+bool(true)
+array(7) {
+  [0]=>
+  float(1050)
+  [1]=>
+  float(10.5)
+  [2]=>
+  float(0.5)
+  [3]=>
+  float(0.106)
+  [4]=>
+  float(0.01)
+  [5]=>
+  float(-0.1)
+  [6]=>
+  float(-10.5)
+}
+
+-- Iteration 3 --
+- With Defualt sort flag -
+bool(true)
+array(11) {
+  [0]=>
+  int(33)
+  [1]=>
+  int(2)
+  [2]=>
+  float(0.106)
+  [3]=>
+  float(0.09)
+  [4]=>
+  float(0.0021)
+  [5]=>
+  float(0.0001)
+  [6]=>
+  int(0)
+  [7]=>
+  float(-0.01)
+  [8]=>
+  float(-0.106)
+  [9]=>
+  float(-0.9)
+  [10]=>
+  int(-1)
+}
+- Sort flag = SORT_REGULAR -
+bool(true)
+array(11) {
+  [0]=>
+  int(33)
+  [1]=>
+  int(2)
+  [2]=>
+  float(0.106)
+  [3]=>
+  float(0.09)
+  [4]=>
+  float(0.0021)
+  [5]=>
+  float(0.0001)
+  [6]=>
+  int(0)
+  [7]=>
+  float(-0.01)
+  [8]=>
+  float(-0.106)
+  [9]=>
+  float(-0.9)
+  [10]=>
+  int(-1)
+}
+- Sort flag = SORT_NUMERIC -
+bool(true)
+array(11) {
+  [0]=>
+  int(33)
+  [1]=>
+  int(2)
+  [2]=>
+  float(0.106)
+  [3]=>
+  float(0.09)
+  [4]=>
+  float(0.0021)
+  [5]=>
+  float(0.0001)
+  [6]=>
+  int(0)
+  [7]=>
+  float(-0.01)
+  [8]=>
+  float(-0.106)
+  [9]=>
+  float(-0.9)
+  [10]=>
+  int(-1)
+}
+
+-- Iteration 4 --
+- With Defualt sort flag -
+bool(true)
+array(7) {
+  [0]=>
+  float(2147483648)
+  [1]=>
+  int(2147483647)
+  [2]=>
+  int(0)
+  [3]=>
+  int(0)
+  [4]=>
+  int(-2147483647)
+  [5]=>
+  float(-2147483648)
+  [6]=>
+  float(-2147483649)
+}
+- Sort flag = SORT_REGULAR -
+bool(true)
+array(7) {
+  [0]=>
+  float(2147483648)
+  [1]=>
+  int(2147483647)
+  [2]=>
+  int(0)
+  [3]=>
+  int(0)
+  [4]=>
+  int(-2147483647)
+  [5]=>
+  float(-2147483648)
+  [6]=>
+  float(-2147483649)
+}
+- Sort flag = SORT_NUMERIC -
+bool(true)
+array(7) {
+  [0]=>
+  float(2147483648)
+  [1]=>
+  int(2147483647)
+  [2]=>
+  int(0)
+  [3]=>
+  int(0)
+  [4]=>
+  int(-2147483647)
+  [5]=>
+  float(-2147483648)
+  [6]=>
+  float(-2147483649)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation4.phpt b/ext/standard/tests/array/rsort_variation4.phpt
new file mode 100644 (file)
index 0000000..abbed35
--- /dev/null
@@ -0,0 +1,78 @@
+--TEST--
+Test rsort() function : usage variations - referenced variables
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test behaviour of rsort() when: 
+ * 1. passed an array of referenced variables
+ * 2. $array_arg is a reference to another array
+ * 3. $array_arg is passed by reference
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+$value1 = 100;
+$value2 = 33;
+$value3 = 555;
+
+// an array containing integer references 
+$unsorted_numerics =  array( &$value1 , &$value2, &$value3);
+
+echo "\n-- 'flag' value is defualt --\n";
+$temp_array = $unsorted_numerics;
+var_dump( rsort($temp_array) );
+var_dump( $temp_array);
+
+echo "\n-- 'flag' = SORT_REGULAR --\n";
+$temp_array = &$unsorted_numerics;
+var_dump( rsort($temp_array, SORT_REGULAR) );
+var_dump( $temp_array);
+
+echo "\n-- 'flag' = SORT_NUMERIC --\n";
+$temp_array = $unsorted_numerics;
+var_dump( rsort(&$temp_array, SORT_NUMERIC) );
+var_dump( $temp_array);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- 'flag' value is defualt --
+bool(true)
+array(3) {
+  [0]=>
+  &int(555)
+  [1]=>
+  &int(100)
+  [2]=>
+  &int(33)
+}
+
+-- 'flag' = SORT_REGULAR --
+bool(true)
+array(3) {
+  [0]=>
+  &int(555)
+  [1]=>
+  &int(100)
+  [2]=>
+  &int(33)
+}
+
+-- 'flag' = SORT_NUMERIC --
+bool(true)
+array(3) {
+  [0]=>
+  &int(555)
+  [1]=>
+  &int(100)
+  [2]=>
+  &int(33)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation5.phpt b/ext/standard/tests/array/rsort_variation5.phpt
new file mode 100644 (file)
index 0000000..eba6bc4
--- /dev/null
@@ -0,0 +1,221 @@
+--TEST--
+Test rsort() function : usage variations - String values
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass arrays containing different string data to rsort() to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+$various_arrays = array (
+// group of escape sequences
+array(null, NULL, "\a", "\cx", "\e", "\f", "\n", "\t", "\xhh", "\ddd", "\v"),
+
+// array contains combination of capital/small letters
+array("lemoN", "Orange", "banana", "apple", "Test", "TTTT", "ttt", "ww", "x", "X", "oraNGe", "BANANA")
+);
+
+$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING);
+
+$count = 1;
+// loop through to test rsort() with different arrays
+foreach ($various_arrays as $array) {
+       echo "\n-- Iteration $count --\n";
+
+       echo "- With Default sort flag -\n";
+       $temp_array = $array;
+       var_dump(rsort($temp_array) );
+       var_dump($temp_array);
+
+       // loop through $flags array and setting all possible flag values
+       foreach($flags as $key => $flag){
+               echo "- Sort flag = $key -\n";
+               
+               $temp_array = $array;
+               var_dump(rsort($temp_array, $flag) );
+               var_dump($temp_array);
+       }
+       $count++;
+}
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- Iteration 1 --
+- With Default sort flag -
+bool(true)
+array(11) {
+  [0]=>
+  string(4) "\xhh"
+  [1]=>
+  string(2) "\e"
+  [2]=>
+  string(4) "\ddd"
+  [3]=>
+  string(3) "\cx"
+  [4]=>
+  string(2) "\a"
+  [5]=>
+  string(1) "\f"
+  [6]=>
+  string(1) "\v"
+  [7]=>
+  string(1) "
+"
+  [8]=>
+  string(1) "  "
+  [9]=>
+  NULL
+  [10]=>
+  NULL
+}
+- Sort flag = SORT_REGULAR -
+bool(true)
+array(11) {
+  [0]=>
+  string(4) "\xhh"
+  [1]=>
+  string(2) "\e"
+  [2]=>
+  string(4) "\ddd"
+  [3]=>
+  string(3) "\cx"
+  [4]=>
+  string(2) "\a"
+  [5]=>
+  string(1) "\f"
+  [6]=>
+  string(1) "\v"
+  [7]=>
+  string(1) "
+"
+  [8]=>
+  string(1) "  "
+  [9]=>
+  NULL
+  [10]=>
+  NULL
+}
+- Sort flag = SORT_STRING -
+bool(true)
+array(11) {
+  [0]=>
+  string(4) "\xhh"
+  [1]=>
+  string(2) "\e"
+  [2]=>
+  string(4) "\ddd"
+  [3]=>
+  string(3) "\cx"
+  [4]=>
+  string(2) "\a"
+  [5]=>
+  string(1) "\f"
+  [6]=>
+  string(1) "\v"
+  [7]=>
+  string(1) "
+"
+  [8]=>
+  string(1) "  "
+  [9]=>
+  NULL
+  [10]=>
+  NULL
+}
+
+-- Iteration 2 --
+- With Default sort flag -
+bool(true)
+array(12) {
+  [0]=>
+  string(1) "x"
+  [1]=>
+  string(2) "ww"
+  [2]=>
+  string(3) "ttt"
+  [3]=>
+  string(6) "oraNGe"
+  [4]=>
+  string(5) "lemoN"
+  [5]=>
+  string(6) "banana"
+  [6]=>
+  string(5) "apple"
+  [7]=>
+  string(1) "X"
+  [8]=>
+  string(4) "Test"
+  [9]=>
+  string(4) "TTTT"
+  [10]=>
+  string(6) "Orange"
+  [11]=>
+  string(6) "BANANA"
+}
+- Sort flag = SORT_REGULAR -
+bool(true)
+array(12) {
+  [0]=>
+  string(1) "x"
+  [1]=>
+  string(2) "ww"
+  [2]=>
+  string(3) "ttt"
+  [3]=>
+  string(6) "oraNGe"
+  [4]=>
+  string(5) "lemoN"
+  [5]=>
+  string(6) "banana"
+  [6]=>
+  string(5) "apple"
+  [7]=>
+  string(1) "X"
+  [8]=>
+  string(4) "Test"
+  [9]=>
+  string(4) "TTTT"
+  [10]=>
+  string(6) "Orange"
+  [11]=>
+  string(6) "BANANA"
+}
+- Sort flag = SORT_STRING -
+bool(true)
+array(12) {
+  [0]=>
+  string(1) "x"
+  [1]=>
+  string(2) "ww"
+  [2]=>
+  string(3) "ttt"
+  [3]=>
+  string(6) "oraNGe"
+  [4]=>
+  string(5) "lemoN"
+  [5]=>
+  string(6) "banana"
+  [6]=>
+  string(5) "apple"
+  [7]=>
+  string(1) "X"
+  [8]=>
+  string(4) "Test"
+  [9]=>
+  string(4) "TTTT"
+  [10]=>
+  string(6) "Orange"
+  [11]=>
+  string(6) "BANANA"
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation6.phpt b/ext/standard/tests/array/rsort_variation6.phpt
new file mode 100644 (file)
index 0000000..559a1eb
--- /dev/null
@@ -0,0 +1,120 @@
+--TEST--
+Test rsort() function : usage variations - Hexadecimal vales
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass rsort() an array of hexadecimal values to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// an array contains unsorted hexadecimal values  
+$unsorted_hex_array = array(0x1AB, 0xFFF, 0xF, 0xFF, 0x2AA, 0xBB, 0x1ab, 0xff, -0xFF, 0, -0x2aa);
+
+echo "\n-- 'flag' value is defualt  --\n";
+$temp_array = $unsorted_hex_array;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+echo "\n-- 'flag' value is SORT_REGULAR  --\n";
+$temp_array = $unsorted_hex_array;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+echo "\n-- 'flag' value is SORT_NUMERIC  --\n";
+$temp_array = $unsorted_hex_array;
+var_dump(rsort($temp_array, SORT_NUMERIC) );
+var_dump($temp_array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- 'flag' value is defualt  --
+bool(true)
+array(11) {
+  [0]=>
+  int(4095)
+  [1]=>
+  int(682)
+  [2]=>
+  int(427)
+  [3]=>
+  int(427)
+  [4]=>
+  int(255)
+  [5]=>
+  int(255)
+  [6]=>
+  int(187)
+  [7]=>
+  int(15)
+  [8]=>
+  int(0)
+  [9]=>
+  int(-255)
+  [10]=>
+  int(-682)
+}
+
+-- 'flag' value is SORT_REGULAR  --
+bool(true)
+array(11) {
+  [0]=>
+  int(4095)
+  [1]=>
+  int(682)
+  [2]=>
+  int(427)
+  [3]=>
+  int(427)
+  [4]=>
+  int(255)
+  [5]=>
+  int(255)
+  [6]=>
+  int(187)
+  [7]=>
+  int(15)
+  [8]=>
+  int(0)
+  [9]=>
+  int(-255)
+  [10]=>
+  int(-682)
+}
+
+-- 'flag' value is SORT_NUMERIC  --
+bool(true)
+array(11) {
+  [0]=>
+  int(4095)
+  [1]=>
+  int(682)
+  [2]=>
+  int(427)
+  [3]=>
+  int(427)
+  [4]=>
+  int(255)
+  [5]=>
+  int(255)
+  [6]=>
+  int(187)
+  [7]=>
+  int(15)
+  [8]=>
+  int(0)
+  [9]=>
+  int(-255)
+  [10]=>
+  int(-682)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation7.phpt b/ext/standard/tests/array/rsort_variation7.phpt
new file mode 100644 (file)
index 0000000..a996bf6
--- /dev/null
@@ -0,0 +1,96 @@
+--TEST--
+Test rsort() function : usage variations - boolean values
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass rsort() arrays of boolean values to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// bool value array
+$bool_values = array (true, false, TRUE, FALSE);
+
+echo "\n-- 'flag' value is defualt --\n";
+$temp_array = $bool_values;
+var_dump(rsort($temp_array) );
+var_dump($temp_array);
+
+echo "\n-- 'flag' value is SORT_REGULAR --\n";
+$temp_array = $bool_values;
+var_dump(rsort($temp_array, SORT_REGULAR) );
+var_dump($temp_array);
+
+echo "\n-- 'flag' value is SORT_NUMERIC  --\n";
+$temp_array = $bool_values;
+var_dump(rsort($temp_array, SORT_NUMERIC) );
+var_dump($temp_array);
+
+echo "\n-- 'flag' value is SORT_STRING --\n";
+$temp_array = $bool_values;
+var_dump(rsort($temp_array, SORT_STRING) );
+var_dump($temp_array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- 'flag' value is defualt --
+bool(true)
+array(4) {
+  [0]=>
+  bool(true)
+  [1]=>
+  bool(true)
+  [2]=>
+  bool(false)
+  [3]=>
+  bool(false)
+}
+
+-- 'flag' value is SORT_REGULAR --
+bool(true)
+array(4) {
+  [0]=>
+  bool(true)
+  [1]=>
+  bool(true)
+  [2]=>
+  bool(false)
+  [3]=>
+  bool(false)
+}
+
+-- 'flag' value is SORT_NUMERIC  --
+bool(true)
+array(4) {
+  [0]=>
+  bool(true)
+  [1]=>
+  bool(true)
+  [2]=>
+  bool(false)
+  [3]=>
+  bool(false)
+}
+
+-- 'flag' value is SORT_STRING --
+bool(true)
+array(4) {
+  [0]=>
+  bool(true)
+  [1]=>
+  bool(true)
+  [2]=>
+  bool(false)
+  [3]=>
+  bool(false)
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation8.phpt b/ext/standard/tests/array/rsort_variation8.phpt
new file mode 100644 (file)
index 0000000..a4f94b5
--- /dev/null
@@ -0,0 +1,180 @@
+--TEST--
+Test rsort() function : usage variations - multi-dimensional arrays
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass rsort() multi-dimensional arrays to test behaviour
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// array of arrays
+$various_arrays = array (
+  // null array
+  array(),
+
+  // array contains null sub array
+  array( array() ),
+
+  // array of arrays along with some values
+  array(44, 11, array(64, 61) ),
+
+  // array containing sub arrays
+  array(array(33, -5, 6), array(11), array(22, -55), array() )
+);
+
+
+$count = 1;
+
+// loop through to test rsort() with different arrays
+foreach ($various_arrays as $array) {
+  echo "\n-- Iteration $count --\n"; 
+  
+  echo "\n-- 'flag' value is default --\n";
+  $temp_array = $array;
+  var_dump(rsort($temp_array) );
+  var_dump($temp_array);
+  
+  echo "\n-- 'flag' value is SORT_REGULAR --\n";
+  $temp_array = $array;
+  var_dump(rsort($temp_array, SORT_REGULAR) );
+  var_dump($temp_array);
+  $count++;
+}
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- Iteration 1 --
+
+-- 'flag' value is default --
+bool(true)
+array(0) {
+}
+
+-- 'flag' value is SORT_REGULAR --
+bool(true)
+array(0) {
+}
+
+-- Iteration 2 --
+
+-- 'flag' value is default --
+bool(true)
+array(1) {
+  [0]=>
+  array(0) {
+  }
+}
+
+-- 'flag' value is SORT_REGULAR --
+bool(true)
+array(1) {
+  [0]=>
+  array(0) {
+  }
+}
+
+-- Iteration 3 --
+
+-- 'flag' value is default --
+bool(true)
+array(3) {
+  [0]=>
+  array(2) {
+    [0]=>
+    int(64)
+    [1]=>
+    int(61)
+  }
+  [1]=>
+  int(44)
+  [2]=>
+  int(11)
+}
+
+-- 'flag' value is SORT_REGULAR --
+bool(true)
+array(3) {
+  [0]=>
+  array(2) {
+    [0]=>
+    int(64)
+    [1]=>
+    int(61)
+  }
+  [1]=>
+  int(44)
+  [2]=>
+  int(11)
+}
+
+-- Iteration 4 --
+
+-- 'flag' value is default --
+bool(true)
+array(4) {
+  [0]=>
+  array(3) {
+    [0]=>
+    int(33)
+    [1]=>
+    int(-5)
+    [2]=>
+    int(6)
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    int(22)
+    [1]=>
+    int(-55)
+  }
+  [2]=>
+  array(1) {
+    [0]=>
+    int(11)
+  }
+  [3]=>
+  array(0) {
+  }
+}
+
+-- 'flag' value is SORT_REGULAR --
+bool(true)
+array(4) {
+  [0]=>
+  array(3) {
+    [0]=>
+    int(33)
+    [1]=>
+    int(-5)
+    [2]=>
+    int(6)
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    int(22)
+    [1]=>
+    int(-55)
+  }
+  [2]=>
+  array(1) {
+    [0]=>
+    int(11)
+  }
+  [3]=>
+  array(0) {
+  }
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/array/rsort_variation9.phpt b/ext/standard/tests/array/rsort_variation9.phpt
new file mode 100644 (file)
index 0000000..c08791d
--- /dev/null
@@ -0,0 +1,259 @@
+--TEST--
+Test rsort() function : usage variations - mixed associative arrays
+--FILE--
+<?php
+/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
+ * Description: Sort an array in reverse order 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass rsort() associative arrays to test key re-assignment
+ */
+
+echo "*** Testing rsort() : variation ***\n";
+
+// Associative arrays
+$various_arrays = array(
+       // numeric assoc. only array
+       array(5 => 55, 6 => 66, 2 => 22, 3 => 33, 1 => 11),
+
+       // two-dimensional assoc. and default key array
+       array("fruits"  => array("a" => "orange", "b" => "banana", "c" => "apple"),
+         "numbers" => array(1, 2, 3, 4, 5, 6),
+         "holes"   => array("first", 5 => "second", "third")),
+
+       // numeric assoc. and default key array
+       array(1, 1, 8 => 1,  4 => 1, 19, 3 => 13),
+
+       // mixed assoc. array
+       array('bar' => 'baz', "foo" => 1),
+
+       // assoc. only multi-dimensional array
+       array('a' => 1,'b' => array('e' => 2,'f' => 3),'c' => array('g' => 4),'d' => 5),
+);
+
+$count = 1;
+
+// loop through to test rsort() with different arrays, 
+// to test the new keys for the elements in the sorted array 
+foreach ($various_arrays as $array) {
+  echo "\n-- Iteration $count --\n";
+
+  echo "-- Sort flag = default --\n";
+  $temp_array = $array;
+  var_dump(rsort($temp_array) );
+  var_dump($temp_array);
+
+  echo "-- Sort flag = SORT_REGULAR --\n";
+  $temp_array = $array;
+  var_dump(rsort($temp_array, SORT_REGULAR) );
+  var_dump($temp_array);
+  $count++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing rsort() : variation ***
+
+-- Iteration 1 --
+-- Sort flag = default --
+bool(true)
+array(5) {
+  [0]=>
+  int(66)
+  [1]=>
+  int(55)
+  [2]=>
+  int(33)
+  [3]=>
+  int(22)
+  [4]=>
+  int(11)
+}
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(5) {
+  [0]=>
+  int(66)
+  [1]=>
+  int(55)
+  [2]=>
+  int(33)
+  [3]=>
+  int(22)
+  [4]=>
+  int(11)
+}
+
+-- Iteration 2 --
+-- Sort flag = default --
+bool(true)
+array(3) {
+  [0]=>
+  array(6) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+    [3]=>
+    int(4)
+    [4]=>
+    int(5)
+    [5]=>
+    int(6)
+  }
+  [1]=>
+  array(3) {
+    [0]=>
+    string(5) "first"
+    [5]=>
+    string(6) "second"
+    [6]=>
+    string(5) "third"
+  }
+  [2]=>
+  array(3) {
+    ["a"]=>
+    string(6) "orange"
+    ["b"]=>
+    string(6) "banana"
+    ["c"]=>
+    string(5) "apple"
+  }
+}
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(3) {
+  [0]=>
+  array(6) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+    [3]=>
+    int(4)
+    [4]=>
+    int(5)
+    [5]=>
+    int(6)
+  }
+  [1]=>
+  array(3) {
+    [0]=>
+    string(5) "first"
+    [5]=>
+    string(6) "second"
+    [6]=>
+    string(5) "third"
+  }
+  [2]=>
+  array(3) {
+    ["a"]=>
+    string(6) "orange"
+    ["b"]=>
+    string(6) "banana"
+    ["c"]=>
+    string(5) "apple"
+  }
+}
+
+-- Iteration 3 --
+-- Sort flag = default --
+bool(true)
+array(6) {
+  [0]=>
+  int(19)
+  [1]=>
+  int(13)
+  [2]=>
+  int(1)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+  [5]=>
+  int(1)
+}
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(6) {
+  [0]=>
+  int(19)
+  [1]=>
+  int(13)
+  [2]=>
+  int(1)
+  [3]=>
+  int(1)
+  [4]=>
+  int(1)
+  [5]=>
+  int(1)
+}
+
+-- Iteration 4 --
+-- Sort flag = default --
+bool(true)
+array(2) {
+  [0]=>
+  int(1)
+  [1]=>
+  string(3) "baz"
+}
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(2) {
+  [0]=>
+  int(1)
+  [1]=>
+  string(3) "baz"
+}
+
+-- Iteration 5 --
+-- Sort flag = default --
+bool(true)
+array(4) {
+  [0]=>
+  array(2) {
+    ["e"]=>
+    int(2)
+    ["f"]=>
+    int(3)
+  }
+  [1]=>
+  array(1) {
+    ["g"]=>
+    int(4)
+  }
+  [2]=>
+  int(5)
+  [3]=>
+  int(1)
+}
+-- Sort flag = SORT_REGULAR --
+bool(true)
+array(4) {
+  [0]=>
+  array(2) {
+    ["e"]=>
+    int(2)
+    ["f"]=>
+    int(3)
+  }
+  [1]=>
+  array(1) {
+    ["g"]=>
+    int(4)
+  }
+  [2]=>
+  int(5)
+  [3]=>
+  int(1)
+}
+Done
\ No newline at end of file