cvs: php-src(PHP_5_3) /ext/standard/tests/array rsort_basic.phpt rsort_error.phpt rsort_object1.phpt rsort_object2.phpt rsort_variation1.phpt
rsort_variation10.phpt rsort_variation11.phpt rsort_variation2.phpt rsort_variation3.phpt rsort_variation4.phpt rsort_variation5.phpt
rsort_variation6.phpt rsort_variation7.phpt rsort_variation8.phpt rsort_variation9.phpt
| From: | Josie Messa | Date: | Fri, 15 Feb 2008 16:06:38 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/standard/tests/array rsort_basic.phpt rsort_error.phpt rsort_object1.phpt rsort_object2.phpt rsort_variation1.phpt rsort_variation10.phpt rsort_variation11.phpt rsort_variation2.phpt rsort_variation3.phpt rsort_variation4.phpt rsort_variation5.phpt rsort_variation6.phpt rsort_variation7.phpt rsort_variation8.phpt rsort_variation9.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-48572@lists.php.net to get a copy of this message | ||
jmessa Fri Feb 15 16:06:38 2008 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array rsort_error.phpt
rsort_variation9.phpt
rsort_variation5.phpt
rsort_variation7.phpt
rsort_object1.phpt
rsort_variation6.phpt
rsort_variation10.phpt
rsort_variation8.phpt
rsort_basic.phpt
rsort_variation11.phpt
rsort_variation4.phpt
rsort_object2.phpt
rsort_variation1.phpt
rsort_variation2.phpt
rsort_variation3.phpt
Log:
- New tests for rsort() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_error.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_error.phpt +++ php-src/ext/standard/tests/array/rsort_error.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation9.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation9.phpt +++ php-src/ext/standard/tests/array/rsort_variation9.phpt --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 --UEXPECTF-- *** 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]=> unicode(5) "first" [5]=> unicode(6) "second" [6]=> unicode(5) "third" } [2]=> array(3) { [u"a"]=> unicode(6) "orange" [u"b"]=> unicode(6) "banana" [u"c"]=> unicode(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]=> unicode(5) "first" [5]=> unicode(6) "second" [6]=> unicode(5) "third" } [2]=> array(3) { [u"a"]=> unicode(6) "orange" [u"b"]=> unicode(6) "banana" [u"c"]=> unicode(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]=> unicode(3) "baz" } -- Sort flag = SORT_REGULAR -- bool(true) array(2) { [0]=> int(1) [1]=> unicode(3) "baz" } -- Iteration 5 -- -- Sort flag = default -- bool(true) array(4) { [0]=> array(2) { [u"e"]=> int(2) [u"f"]=> int(3) } [1]=> array(1) { [u"g"]=> int(4) } [2]=> int(5) [3]=> int(1) } -- Sort flag = SORT_REGULAR -- bool(true) array(4) { [0]=> array(2) { [u"e"]=> int(2) [u"f"]=> int(3) } [1]=> array(1) { [u"g"]=> int(4) } [2]=> int(5) [3]=> int(1) } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation5.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation5.phpt +++ php-src/ext/standard/tests/array/rsort_variation5.phpt --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) "" [6]=> string(1) "" [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) "" [6]=> string(1) "" [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) "" [6]=> string(1) "" [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 --UEXPECTF-- *** Testing rsort() : variation *** -- Iteration 1 -- - With Default sort flag - bool(true) array(11) { [0]=> unicode(4) "\xhh" [1]=> unicode(2) "\e" [2]=> unicode(4) "\ddd" [3]=> unicode(3) "\cx" [4]=> unicode(2) "\a" [5]=> unicode(1) "" [6]=> unicode(1) "" [7]=> unicode(1) " " [8]=> unicode(1) " " [9]=> NULL [10]=> NULL } - Sort flag = SORT_REGULAR - bool(true) array(11) { [0]=> unicode(4) "\xhh" [1]=> unicode(2) "\e" [2]=> unicode(4) "\ddd" [3]=> unicode(3) "\cx" [4]=> unicode(2) "\a" [5]=> unicode(1) "" [6]=> unicode(1) "" [7]=> unicode(1) " " [8]=> unicode(1) " " [9]=> NULL [10]=> NULL } - Sort flag = SORT_STRING - bool(true) array(11) { [0]=> unicode(4) "\xhh" [1]=> unicode(2) "\e" [2]=> unicode(4) "\ddd" [3]=> unicode(3) "\cx" [4]=> unicode(2) "\a" [5]=> unicode(1) "" [6]=> unicode(1) "" [7]=> unicode(1) " " [8]=> unicode(1) " " [9]=> NULL [10]=> NULL } -- Iteration 2 -- - With Default sort flag - bool(true) array(12) { [0]=> unicode(1) "x" [1]=> unicode(2) "ww" [2]=> unicode(3) "ttt" [3]=> unicode(6) "oraNGe" [4]=> unicode(5) "lemoN" [5]=> unicode(6) "banana" [6]=> unicode(5) "apple" [7]=> unicode(1) "X" [8]=> unicode(4) "Test" [9]=> unicode(4) "TTTT" [10]=> unicode(6) "Orange" [11]=> unicode(6) "BANANA" } - Sort flag = SORT_REGULAR - bool(true) array(12) { [0]=> unicode(1) "x" [1]=> unicode(2) "ww" [2]=> unicode(3) "ttt" [3]=> unicode(6) "oraNGe" [4]=> unicode(5) "lemoN" [5]=> unicode(6) "banana" [6]=> unicode(5) "apple" [7]=> unicode(1) "X" [8]=> unicode(4) "Test" [9]=> unicode(4) "TTTT" [10]=> unicode(6) "Orange" [11]=> unicode(6) "BANANA" } - Sort flag = SORT_STRING - bool(true) array(12) { [0]=> unicode(1) "x" [1]=> unicode(2) "ww" [2]=> unicode(3) "ttt" [3]=> unicode(6) "oraNGe" [4]=> unicode(5) "lemoN" [5]=> unicode(6) "banana" [6]=> unicode(5) "apple" [7]=> unicode(1) "X" [8]=> unicode(4) "Test" [9]=> unicode(4) "TTTT" [10]=> unicode(6) "Orange" [11]=> unicode(6) "BANANA" } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation7.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation7.phpt +++ php-src/ext/standard/tests/array/rsort_variation7.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_object1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_object1.phpt +++ php-src/ext/standard/tests/array/rsort_object1.phpt --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 --UEXPECTF-- *** Testing rsort() : object functionality *** -- Sort flag = default -- bool(true) array(6) { [0]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(66) } [1]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(23) } [2]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(11) } [3]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> float(0.001) } [4]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(0) } [5]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(-5) } } bool(true) array(8) { [0]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "w" } [1]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "t" } [2]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(2) "py" } [3]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(3) "axx" } [4]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "apple" } [5]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "aPPle" } [6]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(6) "Orange" } [7]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "Lemon" } } -- Sort flag = SORT_REGULAR -- bool(true) array(6) { [0]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(66) } [1]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(23) } [2]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(11) } [3]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> float(0.001) } [4]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(0) } [5]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(-5) } } bool(true) array(8) { [0]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "w" } [1]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "t" } [2]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(2) "py" } [3]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(3) "axx" } [4]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "apple" } [5]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "aPPle" } [6]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(6) "Orange" } [7]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "Lemon" } } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation6.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation6.phpt +++ php-src/ext/standard/tests/array/rsort_variation6.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation10.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation10.phpt +++ php-src/ext/standard/tests/array/rsort_variation10.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation8.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation8.phpt +++ php-src/ext/standard/tests/array/rsort_variation8.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_basic.phpt +++ php-src/ext/standard/tests/array/rsort_basic.phpt --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 --UEXPECTF-- *** Testing rsort() : basic functionality *** -- Testing rsort() by supplying string array, 'flag' value is defualt -- bool(true) array(3) { [0]=> unicode(6) "orange" [1]=> unicode(5) "lemon" [2]=> unicode(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]=> unicode(6) "orange" [1]=> unicode(5) "lemon" [2]=> unicode(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]=> unicode(6) "orange" [1]=> unicode(5) "lemon" [2]=> unicode(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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation11.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation11.phpt +++ php-src/ext/standard/tests/array/rsort_variation11.phpt --TEST-- Test rsort() function : usage variations - mixed array --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 different data types to test behaviour */ echo "*** Testing rsort() : variation ***\n"; // mixed value array $mixed_values = array ( array(), array( array(33, -5, 6), array(11), array(22, -55), array() ), -4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "", NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false ); echo "\n-- Sort flag = default --\n"; $temp_array = $mixed_values; var_dump(rsort($temp_array) ); var_dump($temp_array); echo "\n-- Sort flag = SORT_REGULAR --\n"; $temp_array = $mixed_values; var_dump(rsort($temp_array, SORT_REGULAR) ); var_dump($temp_array); echo "Done"; ?> --EXPECTF-- *** Testing rsort() : variation *** -- Sort flag = default -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> string(1) "b" [3]=> string(14) "abcd [4]=> string(4) "abcd" [5]=> string(2) "ab" [6]=> string(4) "True" [7]=> string(1) "5" [8]=> bool(true) [9]=> string(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> string(3) "-.9" [14]=> string(0) "" [15]=> string(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } -- Sort flag = SORT_REGULAR -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> string(1) "b" [3]=> string(14) "abcd [4]=> string(4) "abcd" [5]=> string(2) "ab" [6]=> string(4) "True" [7]=> string(1) "5" [8]=> bool(true) [9]=> string(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> string(3) "-.9" [14]=> string(0) "" [15]=> string(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } Done --UEXPECTF-- *** Testing rsort() : variation *** -- Sort flag = default -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> unicode(1) "b" [3]=> unicode(14) "abcd [4]=> unicode(4) "abcd" [5]=> unicode(2) "ab" [6]=> unicode(4) "True" [7]=> unicode(1) "5" [8]=> bool(true) [9]=> unicode(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> unicode(3) "-.9" [14]=> unicode(0) "" [15]=> unicode(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } -- Sort flag = SORT_REGULAR -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> unicode(1) "b" [3]=> unicode(14) "abcd [4]=> unicode(4) "abcd" [5]=> unicode(2) "ab" [6]=> unicode(4) "True" [7]=> unicode(1) "5" [8]=> bool(true) [9]=> unicode(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> unicode(3) "-.9" [14]=> unicode(0) "" [15]=> unicode(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation4.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation4.phpt +++ php-src/ext/standard/tests/array/rsort_variation4.phpt --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-- Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d *** 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 --UEXPECTF-- Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_object2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_object2.phpt +++ php-src/ext/standard/tests/array/rsort_object2.phpt --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":"for_integer_rsort":private]=> int(44) ["protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#%d (3) { ["public_class_value"]=> int(11) ["private_class_value":"for_integer_rsort":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":"for_integer_rsort":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":"for_integer_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_integer_rsort":private]=> int(44) ["protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#%d (3) { ["public_class_value"]=> int(11) ["private_class_value":"for_integer_rsort":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":"for_integer_rsort":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":"for_integer_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":private]=> string(3) "AXX" ["protected_class_value":protected]=> string(3) "ass" } } Done --UEXPECTF-- *** Testing rsort() : object functionality *** -- Sort flag = default -- bool(true) array(4) { [0]=> object(for_integer_rsort)#2 (3) { [u"public_class_value"]=> int(66) [u"private_class_value":u"for_integer_rsort":private]=> int(44) [u"protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#1 (3) { [u"public_class_value"]=> int(11) [u"private_class_value":u"for_integer_rsort":private]=> int(33) [u"protected_class_value":protected]=> int(30) } [2]=> object(for_integer_rsort)#4 (3) { [u"public_class_value"]=> float(0.001) [u"private_class_value":u"for_integer_rsort":private]=> float(99.5) [u"protected_class_value":protected]=> float(0.1) } [3]=> object(for_integer_rsort)#3 (3) { [u"public_class_value"]=> int(-88) [u"private_class_value":u"for_integer_rsort":private]=> int(-5) [u"protected_class_value":protected]=> int(5) } } bool(true) array(4) { [0]=> object(for_string_rsort)#7 (3) { [u"public_class_value"]=> unicode(1) "w" [u"private_class_value":u"for_string_rsort":private]=> unicode(1) "W" [u"protected_class_value":protected]=> unicode(1) "c" } [1]=> object(for_string_rsort)#6 (3) { [u"public_class_value"]=> unicode(1) "t" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "eee" [u"protected_class_value":protected]=> unicode(3) "abb" } [2]=> object(for_string_rsort)#8 (3) { [u"public_class_value"]=> unicode(2) "py" [u"private_class_value":u"for_string_rsort":private]=> unicode(2) "PY" [u"protected_class_value":protected]=> unicode(2) "pt" } [3]=> object(for_string_rsort)#5 (3) { [u"public_class_value"]=> unicode(3) "axx" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "AXX" [u"protected_class_value":protected]=> unicode(3) "ass" } } -- Sort flag = SORT_REGULAR -- bool(true) array(4) { [0]=> object(for_integer_rsort)#2 (3) { [u"public_class_value"]=> int(66) [u"private_class_value":u"for_integer_rsort":private]=> int(44) [u"protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#1 (3) { [u"public_class_value"]=> int(11) [u"private_class_value":u"for_integer_rsort":private]=> int(33) [u"protected_class_value":protected]=> int(30) } [2]=> object(for_integer_rsort)#4 (3) { [u"public_class_value"]=> float(0.001) [u"private_class_value":u"for_integer_rsort":private]=> float(99.5) [u"protected_class_value":protected]=> float(0.1) } [3]=> object(for_integer_rsort)#3 (3) { [u"public_class_value"]=> int(-88) [u"private_class_value":u"for_integer_rsort":private]=> int(-5) [u"protected_class_value":protected]=> int(5) } } bool(true) array(4) { [0]=> object(for_string_rsort)#7 (3) { [u"public_class_value"]=> unicode(1) "w" [u"private_class_value":u"for_string_rsort":private]=> unicode(1) "W" [u"protected_class_value":protected]=> unicode(1) "c" } [1]=> object(for_string_rsort)#6 (3) { [u"public_class_value"]=> unicode(1) "t" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "eee" [u"protected_class_value":protected]=> unicode(3) "abb" } [2]=> object(for_string_rsort)#8 (3) { [u"public_class_value"]=> unicode(2) "py" [u"private_class_value":u"for_string_rsort":private]=> unicode(2) "PY" [u"protected_class_value":protected]=> unicode(2) "pt" } [3]=> object(for_string_rsort)#5 (3) { [u"public_class_value"]=> unicode(3) "axx" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "AXX" [u"protected_class_value":protected]=> unicode(3) "ass" } } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation1.phpt +++ php-src/ext/standard/tests/array/rsort_variation1.phpt --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 --UEXPECTF-- *** 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, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 17 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 18 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 19 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 20 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation2.phpt +++ php-src/ext/standard/tests/array/rsort_variation2.phpt --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 --UEXPECTF-- *** 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation3.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation3.phpt +++ php-src/ext/standard/tests/array/rsort_variation3.phpt --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 --UEXPECTF-- *** 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
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_error.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_error.phpt +++ php-src/ext/standard/tests/array/rsort_error.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation9.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation9.phpt +++ php-src/ext/standard/tests/array/rsort_variation9.phpt --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 --UEXPECTF-- *** 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]=> unicode(5) "first" [5]=> unicode(6) "second" [6]=> unicode(5) "third" } [2]=> array(3) { [u"a"]=> unicode(6) "orange" [u"b"]=> unicode(6) "banana" [u"c"]=> unicode(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]=> unicode(5) "first" [5]=> unicode(6) "second" [6]=> unicode(5) "third" } [2]=> array(3) { [u"a"]=> unicode(6) "orange" [u"b"]=> unicode(6) "banana" [u"c"]=> unicode(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]=> unicode(3) "baz" } -- Sort flag = SORT_REGULAR -- bool(true) array(2) { [0]=> int(1) [1]=> unicode(3) "baz" } -- Iteration 5 -- -- Sort flag = default -- bool(true) array(4) { [0]=> array(2) { [u"e"]=> int(2) [u"f"]=> int(3) } [1]=> array(1) { [u"g"]=> int(4) } [2]=> int(5) [3]=> int(1) } -- Sort flag = SORT_REGULAR -- bool(true) array(4) { [0]=> array(2) { [u"e"]=> int(2) [u"f"]=> int(3) } [1]=> array(1) { [u"g"]=> int(4) } [2]=> int(5) [3]=> int(1) } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation5.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation5.phpt +++ php-src/ext/standard/tests/array/rsort_variation5.phpt --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) "" [6]=> string(1) "" [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) "" [6]=> string(1) "" [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) "" [6]=> string(1) "" [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 --UEXPECTF-- *** Testing rsort() : variation *** -- Iteration 1 -- - With Default sort flag - bool(true) array(11) { [0]=> unicode(4) "\xhh" [1]=> unicode(2) "\e" [2]=> unicode(4) "\ddd" [3]=> unicode(3) "\cx" [4]=> unicode(2) "\a" [5]=> unicode(1) "" [6]=> unicode(1) "" [7]=> unicode(1) " " [8]=> unicode(1) " " [9]=> NULL [10]=> NULL } - Sort flag = SORT_REGULAR - bool(true) array(11) { [0]=> unicode(4) "\xhh" [1]=> unicode(2) "\e" [2]=> unicode(4) "\ddd" [3]=> unicode(3) "\cx" [4]=> unicode(2) "\a" [5]=> unicode(1) "" [6]=> unicode(1) "" [7]=> unicode(1) " " [8]=> unicode(1) " " [9]=> NULL [10]=> NULL } - Sort flag = SORT_STRING - bool(true) array(11) { [0]=> unicode(4) "\xhh" [1]=> unicode(2) "\e" [2]=> unicode(4) "\ddd" [3]=> unicode(3) "\cx" [4]=> unicode(2) "\a" [5]=> unicode(1) "" [6]=> unicode(1) "" [7]=> unicode(1) " " [8]=> unicode(1) " " [9]=> NULL [10]=> NULL } -- Iteration 2 -- - With Default sort flag - bool(true) array(12) { [0]=> unicode(1) "x" [1]=> unicode(2) "ww" [2]=> unicode(3) "ttt" [3]=> unicode(6) "oraNGe" [4]=> unicode(5) "lemoN" [5]=> unicode(6) "banana" [6]=> unicode(5) "apple" [7]=> unicode(1) "X" [8]=> unicode(4) "Test" [9]=> unicode(4) "TTTT" [10]=> unicode(6) "Orange" [11]=> unicode(6) "BANANA" } - Sort flag = SORT_REGULAR - bool(true) array(12) { [0]=> unicode(1) "x" [1]=> unicode(2) "ww" [2]=> unicode(3) "ttt" [3]=> unicode(6) "oraNGe" [4]=> unicode(5) "lemoN" [5]=> unicode(6) "banana" [6]=> unicode(5) "apple" [7]=> unicode(1) "X" [8]=> unicode(4) "Test" [9]=> unicode(4) "TTTT" [10]=> unicode(6) "Orange" [11]=> unicode(6) "BANANA" } - Sort flag = SORT_STRING - bool(true) array(12) { [0]=> unicode(1) "x" [1]=> unicode(2) "ww" [2]=> unicode(3) "ttt" [3]=> unicode(6) "oraNGe" [4]=> unicode(5) "lemoN" [5]=> unicode(6) "banana" [6]=> unicode(5) "apple" [7]=> unicode(1) "X" [8]=> unicode(4) "Test" [9]=> unicode(4) "TTTT" [10]=> unicode(6) "Orange" [11]=> unicode(6) "BANANA" } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation7.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation7.phpt +++ php-src/ext/standard/tests/array/rsort_variation7.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_object1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_object1.phpt +++ php-src/ext/standard/tests/array/rsort_object1.phpt --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 --UEXPECTF-- *** Testing rsort() : object functionality *** -- Sort flag = default -- bool(true) array(6) { [0]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(66) } [1]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(23) } [2]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(11) } [3]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> float(0.001) } [4]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(0) } [5]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(-5) } } bool(true) array(8) { [0]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "w" } [1]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "t" } [2]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(2) "py" } [3]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(3) "axx" } [4]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "apple" } [5]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "aPPle" } [6]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(6) "Orange" } [7]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "Lemon" } } -- Sort flag = SORT_REGULAR -- bool(true) array(6) { [0]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(66) } [1]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(23) } [2]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(11) } [3]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> float(0.001) } [4]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(0) } [5]=> object(for_integer_rsort)#%d (1) { [u"class_value"]=> int(-5) } } bool(true) array(8) { [0]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "w" } [1]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(1) "t" } [2]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(2) "py" } [3]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(3) "axx" } [4]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "apple" } [5]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "aPPle" } [6]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(6) "Orange" } [7]=> object(for_string_rsort)#%d (1) { [u"class_value"]=> unicode(5) "Lemon" } } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation6.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation6.phpt +++ php-src/ext/standard/tests/array/rsort_variation6.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation10.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation10.phpt +++ php-src/ext/standard/tests/array/rsort_variation10.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation8.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation8.phpt +++ php-src/ext/standard/tests/array/rsort_variation8.phpt --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 --UEXPECTF-- *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_basic.phpt +++ php-src/ext/standard/tests/array/rsort_basic.phpt --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 --UEXPECTF-- *** Testing rsort() : basic functionality *** -- Testing rsort() by supplying string array, 'flag' value is defualt -- bool(true) array(3) { [0]=> unicode(6) "orange" [1]=> unicode(5) "lemon" [2]=> unicode(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]=> unicode(6) "orange" [1]=> unicode(5) "lemon" [2]=> unicode(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]=> unicode(6) "orange" [1]=> unicode(5) "lemon" [2]=> unicode(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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation11.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation11.phpt +++ php-src/ext/standard/tests/array/rsort_variation11.phpt --TEST-- Test rsort() function : usage variations - mixed array --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 different data types to test behaviour */ echo "*** Testing rsort() : variation ***\n"; // mixed value array $mixed_values = array ( array(), array( array(33, -5, 6), array(11), array(22, -55), array() ), -4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "", NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false ); echo "\n-- Sort flag = default --\n"; $temp_array = $mixed_values; var_dump(rsort($temp_array) ); var_dump($temp_array); echo "\n-- Sort flag = SORT_REGULAR --\n"; $temp_array = $mixed_values; var_dump(rsort($temp_array, SORT_REGULAR) ); var_dump($temp_array); echo "Done"; ?> --EXPECTF-- *** Testing rsort() : variation *** -- Sort flag = default -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> string(1) "b" [3]=> string(14) "abcd [4]=> string(4) "abcd" [5]=> string(2) "ab" [6]=> string(4) "True" [7]=> string(1) "5" [8]=> bool(true) [9]=> string(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> string(3) "-.9" [14]=> string(0) "" [15]=> string(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } -- Sort flag = SORT_REGULAR -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> string(1) "b" [3]=> string(14) "abcd [4]=> string(4) "abcd" [5]=> string(2) "ab" [6]=> string(4) "True" [7]=> string(1) "5" [8]=> bool(true) [9]=> string(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> string(3) "-.9" [14]=> string(0) "" [15]=> string(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } Done --UEXPECTF-- *** Testing rsort() : variation *** -- Sort flag = default -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> unicode(1) "b" [3]=> unicode(14) "abcd [4]=> unicode(4) "abcd" [5]=> unicode(2) "ab" [6]=> unicode(4) "True" [7]=> unicode(1) "5" [8]=> bool(true) [9]=> unicode(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> unicode(3) "-.9" [14]=> unicode(0) "" [15]=> unicode(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } -- Sort flag = SORT_REGULAR -- bool(true) array(22) { [0]=> array(4) { [0]=> array(3) { [0]=> int(33) [1]=> int(-5) [2]=> int(6) } [1]=> array(1) { [0]=> int(11) } [2]=> array(2) { [0]=> int(22) [1]=> int(-55) } [3]=> array(0) { } } [1]=> array(0) { } [2]=> unicode(1) "b" [3]=> unicode(14) "abcd [4]=> unicode(4) "abcd" [5]=> unicode(2) "ab" [6]=> unicode(4) "True" [7]=> unicode(1) "5" [8]=> bool(true) [9]=> unicode(1) "4" [10]=> float(4) [11]=> float(0) [12]=> int(0) [13]=> unicode(3) "-.9" [14]=> unicode(0) "" [15]=> unicode(0) "" [16]=> int(-2) [17]=> float(-2) [18]=> float(-2.98989) [19]=> int(-4) [20]=> bool(false) [21]=> NULL } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation4.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation4.phpt +++ php-src/ext/standard/tests/array/rsort_variation4.phpt --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-- Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d *** 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 --UEXPECTF-- Strict Standards: Call-time pass-by-reference has been deprecated in %s on line %d *** 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_object2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_object2.phpt +++ php-src/ext/standard/tests/array/rsort_object2.phpt --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":"for_integer_rsort":private]=> int(44) ["protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#%d (3) { ["public_class_value"]=> int(11) ["private_class_value":"for_integer_rsort":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":"for_integer_rsort":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":"for_integer_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_integer_rsort":private]=> int(44) ["protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#%d (3) { ["public_class_value"]=> int(11) ["private_class_value":"for_integer_rsort":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":"for_integer_rsort":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":"for_integer_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":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":"for_string_rsort":private]=> string(3) "AXX" ["protected_class_value":protected]=> string(3) "ass" } } Done --UEXPECTF-- *** Testing rsort() : object functionality *** -- Sort flag = default -- bool(true) array(4) { [0]=> object(for_integer_rsort)#2 (3) { [u"public_class_value"]=> int(66) [u"private_class_value":u"for_integer_rsort":private]=> int(44) [u"protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#1 (3) { [u"public_class_value"]=> int(11) [u"private_class_value":u"for_integer_rsort":private]=> int(33) [u"protected_class_value":protected]=> int(30) } [2]=> object(for_integer_rsort)#4 (3) { [u"public_class_value"]=> float(0.001) [u"private_class_value":u"for_integer_rsort":private]=> float(99.5) [u"protected_class_value":protected]=> float(0.1) } [3]=> object(for_integer_rsort)#3 (3) { [u"public_class_value"]=> int(-88) [u"private_class_value":u"for_integer_rsort":private]=> int(-5) [u"protected_class_value":protected]=> int(5) } } bool(true) array(4) { [0]=> object(for_string_rsort)#7 (3) { [u"public_class_value"]=> unicode(1) "w" [u"private_class_value":u"for_string_rsort":private]=> unicode(1) "W" [u"protected_class_value":protected]=> unicode(1) "c" } [1]=> object(for_string_rsort)#6 (3) { [u"public_class_value"]=> unicode(1) "t" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "eee" [u"protected_class_value":protected]=> unicode(3) "abb" } [2]=> object(for_string_rsort)#8 (3) { [u"public_class_value"]=> unicode(2) "py" [u"private_class_value":u"for_string_rsort":private]=> unicode(2) "PY" [u"protected_class_value":protected]=> unicode(2) "pt" } [3]=> object(for_string_rsort)#5 (3) { [u"public_class_value"]=> unicode(3) "axx" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "AXX" [u"protected_class_value":protected]=> unicode(3) "ass" } } -- Sort flag = SORT_REGULAR -- bool(true) array(4) { [0]=> object(for_integer_rsort)#2 (3) { [u"public_class_value"]=> int(66) [u"private_class_value":u"for_integer_rsort":private]=> int(44) [u"protected_class_value":protected]=> int(4) } [1]=> object(for_integer_rsort)#1 (3) { [u"public_class_value"]=> int(11) [u"private_class_value":u"for_integer_rsort":private]=> int(33) [u"protected_class_value":protected]=> int(30) } [2]=> object(for_integer_rsort)#4 (3) { [u"public_class_value"]=> float(0.001) [u"private_class_value":u"for_integer_rsort":private]=> float(99.5) [u"protected_class_value":protected]=> float(0.1) } [3]=> object(for_integer_rsort)#3 (3) { [u"public_class_value"]=> int(-88) [u"private_class_value":u"for_integer_rsort":private]=> int(-5) [u"protected_class_value":protected]=> int(5) } } bool(true) array(4) { [0]=> object(for_string_rsort)#7 (3) { [u"public_class_value"]=> unicode(1) "w" [u"private_class_value":u"for_string_rsort":private]=> unicode(1) "W" [u"protected_class_value":protected]=> unicode(1) "c" } [1]=> object(for_string_rsort)#6 (3) { [u"public_class_value"]=> unicode(1) "t" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "eee" [u"protected_class_value":protected]=> unicode(3) "abb" } [2]=> object(for_string_rsort)#8 (3) { [u"public_class_value"]=> unicode(2) "py" [u"private_class_value":u"for_string_rsort":private]=> unicode(2) "PY" [u"protected_class_value":protected]=> unicode(2) "pt" } [3]=> object(for_string_rsort)#5 (3) { [u"public_class_value"]=> unicode(3) "axx" [u"private_class_value":u"for_string_rsort":private]=> unicode(3) "AXX" [u"protected_class_value":protected]=> unicode(3) "ass" } } Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation1.phpt +++ php-src/ext/standard/tests/array/rsort_variation1.phpt --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 --UEXPECTF-- *** 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, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 17 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 18 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 19 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) -- Iteration 20 -- Flag = default: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_REGULAR: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_NUMERIC: Warning: rsort() expects parameter 1 to be array, Unicode string given in %s on line %d bool(false) Flag = SORT_STRING: Warning: rsort() expects parameter 1 to be array, Unicode 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation2.phpt +++ php-src/ext/standard/tests/array/rsort_variation2.phpt --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 --UEXPECTF-- *** 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/rsort_variation3.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/rsort_variation3.phpt +++ php-src/ext/standard/tests/array/rsort_variation3.phpt --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 --UEXPECTF-- *** 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