From 9da1ec78c0ad8b8bcabbacdf24ff4fb4351e6513 Mon Sep 17 00:00:00 2001 From: Josie Messa Date: Fri, 15 Feb 2008 16:05:28 +0000 Subject: [PATCH] - New tests for rsort() function --- ext/standard/tests/array/rsort_basic.phpt | 129 +++++ ext/standard/tests/array/rsort_error.phpt | 51 ++ ext/standard/tests/array/rsort_object1.phpt | 243 +++++++++ ext/standard/tests/array/rsort_object2.phpt | 258 +++++++++ .../tests/array/rsort_variation1.phpt | 514 ++++++++++++++++++ .../tests/array/rsort_variation10.phpt | 108 ++++ .../tests/array/rsort_variation11.phpt | Bin 0 -> 2695 bytes .../tests/array/rsort_variation2.phpt | 484 +++++++++++++++++ .../tests/array/rsort_variation3.phpt | 321 +++++++++++ .../tests/array/rsort_variation4.phpt | 78 +++ .../tests/array/rsort_variation5.phpt | 221 ++++++++ .../tests/array/rsort_variation6.phpt | 120 ++++ .../tests/array/rsort_variation7.phpt | 96 ++++ .../tests/array/rsort_variation8.phpt | 180 ++++++ .../tests/array/rsort_variation9.phpt | 259 +++++++++ 15 files changed, 3062 insertions(+) create mode 100644 ext/standard/tests/array/rsort_basic.phpt create mode 100644 ext/standard/tests/array/rsort_error.phpt create mode 100644 ext/standard/tests/array/rsort_object1.phpt create mode 100644 ext/standard/tests/array/rsort_object2.phpt create mode 100644 ext/standard/tests/array/rsort_variation1.phpt create mode 100644 ext/standard/tests/array/rsort_variation10.phpt create mode 100644 ext/standard/tests/array/rsort_variation11.phpt create mode 100644 ext/standard/tests/array/rsort_variation2.phpt create mode 100644 ext/standard/tests/array/rsort_variation3.phpt create mode 100644 ext/standard/tests/array/rsort_variation4.phpt create mode 100644 ext/standard/tests/array/rsort_variation5.phpt create mode 100644 ext/standard/tests/array/rsort_variation6.phpt create mode 100644 ext/standard/tests/array/rsort_variation7.phpt create mode 100644 ext/standard/tests/array/rsort_variation8.phpt create mode 100644 ext/standard/tests/array/rsort_variation9.phpt diff --git a/ext/standard/tests/array/rsort_basic.phpt b/ext/standard/tests/array/rsort_basic.phpt new file mode 100644 index 0000000000..5495be9257 --- /dev/null +++ b/ext/standard/tests/array/rsort_basic.phpt @@ -0,0 +1,129 @@ +--TEST-- +Test rsort() function : basic functionality +--FILE-- + "lemon", "o" => "orange", "b" => "banana" ); + +// array with default keys containing unsorted numeric values +$unsorted_numerics = array( 100, 33, 555, 22 ); + +echo "\n-- Testing rsort() by supplying string array, 'flag' value is defualt --\n"; +$temp_array = $unsorted_strings; +var_dump( rsort($temp_array) ); +var_dump( $temp_array); + +echo "\n-- Testing rsort() by supplying numeric array, 'flag' value is defualt --\n"; +$temp_array = $unsorted_numerics; +var_dump( rsort($temp_array) ); +var_dump( $temp_array); + +echo "\n-- Testing rsort() by supplying string array, 'flag' = SORT_REGULAR --\n"; +$temp_array = $unsorted_strings; +var_dump( rsort($temp_array, SORT_REGULAR) ); +var_dump( $temp_array); + +echo "\n-- Testing rsort() by supplying numeric array, 'flag' = SORT_REGULAR --\n"; +$temp_array = $unsorted_numerics; +var_dump( rsort($temp_array, SORT_REGULAR) ); +var_dump( $temp_array); + +echo "\n-- Testing rsort() by supplying string array, 'flag' = SORT_STRING --\n"; +$temp_array = $unsorted_strings; +var_dump( rsort($temp_array, SORT_STRING) ); +var_dump( $temp_array); + +echo "\n-- Testing rsort() by supplying numeric array, 'flag' = SORT_NUMERIC --\n"; +$temp_array = $unsorted_numerics; +var_dump( rsort($temp_array, SORT_NUMERIC) ); +var_dump( $temp_array); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing rsort() : basic functionality *** + +-- Testing rsort() by supplying string array, 'flag' value is defualt -- +bool(true) +array(3) { + [0]=> + string(6) "orange" + [1]=> + string(5) "lemon" + [2]=> + string(6) "banana" +} + +-- Testing rsort() by supplying numeric array, 'flag' value is defualt -- +bool(true) +array(4) { + [0]=> + int(555) + [1]=> + int(100) + [2]=> + int(33) + [3]=> + int(22) +} + +-- Testing rsort() by supplying string array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [0]=> + string(6) "orange" + [1]=> + string(5) "lemon" + [2]=> + string(6) "banana" +} + +-- Testing rsort() by supplying numeric array, 'flag' = SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + int(555) + [1]=> + int(100) + [2]=> + int(33) + [3]=> + int(22) +} + +-- Testing rsort() by supplying string array, 'flag' = SORT_STRING -- +bool(true) +array(3) { + [0]=> + string(6) "orange" + [1]=> + string(5) "lemon" + [2]=> + string(6) "banana" +} + +-- Testing rsort() by supplying numeric array, 'flag' = SORT_NUMERIC -- +bool(true) +array(4) { + [0]=> + int(555) + [1]=> + int(100) + [2]=> + int(33) + [3]=> + int(22) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_error.phpt b/ext/standard/tests/array/rsort_error.phpt new file mode 100644 index 0000000000..6f6f2f9762 --- /dev/null +++ b/ext/standard/tests/array/rsort_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test rsort() function : error conditions - Pass incorrect number of args +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : error conditions *** + +-- Testing rsort() function with Zero arguments -- + +Warning: rsort() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing rsort() function with more than expected no. of arguments -- + +Warning: rsort() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_object1.phpt b/ext/standard/tests/array/rsort_object1.phpt new file mode 100644 index 0000000000..98f7cfec16 --- /dev/null +++ b/ext/standard/tests/array/rsort_object1.phpt @@ -0,0 +1,243 @@ +--TEST-- +Test rsort() function : object functionality +--FILE-- +class_value = $value; + } + +} + +// class declaration for string objects +class for_string_rsort +{ + public $class_value; + // initializing object member value + function __construct($value){ + $this->class_value = $value; + } + + // return string value + function __tostring() { + return (string)$this->value; + } + +} + +// array of integer objects +$unsorted_int_obj = array( + new for_integer_rsort(11), new for_integer_rsort(66), + new for_integer_rsort(23), new for_integer_rsort(-5), + new for_integer_rsort(0.001), new for_integer_rsort(0) +); + +// array of string objects +$unsorted_str_obj = array ( + new for_string_rsort("axx"), new for_string_rsort("t"), + new for_string_rsort("w"), new for_string_rsort("py"), + new for_string_rsort("apple"), new for_string_rsort("Orange"), + new for_string_rsort("Lemon"), new for_string_rsort("aPPle") +); + + +echo "\n-- Sort flag = default --\n"; + +// testing rsort() function by supplying integer object array, flag value is defualt +$temp_array = $unsorted_int_obj; +var_dump(rsort($temp_array) ); +var_dump($temp_array); + +// testing rsort() function by supplying string object array, flag value is defualt +$temp_array = $unsorted_str_obj; +var_dump(rsort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Sort flag = SORT_REGULAR --\n"; +// testing rsort() function by supplying integer object array, flag value = SORT_REGULAR +$temp_array = $unsorted_int_obj; +var_dump(rsort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +// testing rsort() function by supplying string object array, flag value = SORT_REGULAR +$temp_array = $unsorted_str_obj; +var_dump(rsort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing rsort() : object functionality *** + +-- Sort flag = default -- +bool(true) +array(6) { + [0]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(66) + } + [1]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(23) + } + [2]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(11) + } + [3]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + float(0.001) + } + [4]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(0) + } + [5]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(-5) + } +} +bool(true) +array(8) { + [0]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(1) "w" + } + [1]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + [2]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + [3]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + [4]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + [5]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + [6]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + [7]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } +} + +-- Sort flag = SORT_REGULAR -- +bool(true) +array(6) { + [0]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(66) + } + [1]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(23) + } + [2]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(11) + } + [3]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + float(0.001) + } + [4]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(0) + } + [5]=> + object(for_integer_rsort)#%d (1) { + ["class_value"]=> + int(-5) + } +} +bool(true) +array(8) { + [0]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(1) "w" + } + [1]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + [2]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + [3]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + [4]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + [5]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + [6]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + [7]=> + object(for_string_rsort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_object2.phpt b/ext/standard/tests/array/rsort_object2.phpt new file mode 100644 index 0000000000..216d3c9101 --- /dev/null +++ b/ext/standard/tests/array/rsort_object2.phpt @@ -0,0 +1,258 @@ +--TEST-- +Test rsort() function : object functionality - different visibilities +--FILE-- +public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } + +} + +// class declaration for string objects +class for_string_rsort +{ + public $public_class_value; + private $private_class_value; + protected $protected_class_value; + // initializing object member value + function __construct($value1, $value2,$value3){ + $this->public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } + + // return string value + function __tostring() { + return (string)$this->value; + } + +} + +// array of integer objects + +$unsorted_int_obj = array( + new for_integer_rsort(11,33,30), + new for_integer_rsort(66,44,4), + new for_integer_rsort(-88,-5,5), + new for_integer_rsort(0.001,99.5,0.1) +); + +// array of string objects +$unsorted_str_obj = array ( + new for_string_rsort("axx","AXX","ass"), + new for_string_rsort("t","eee","abb"), + new for_string_rsort("w","W", "c"), + new for_string_rsort("py","PY", "pt"), +); + + +echo "\n-- Sort flag = default --\n"; + +// testing rsort() function by supplying integer object array, flag value is defualt +$temp_array = $unsorted_int_obj; +var_dump(rsort($temp_array) ); +var_dump($temp_array); + +// testing rsort() function by supplying string object array, flag value is defualt +$temp_array = $unsorted_str_obj; +var_dump(rsort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Sort flag = SORT_REGULAR --\n"; +// testing rsort() function by supplying integer object array, flag value = SORT_REGULAR +$temp_array = $unsorted_int_obj; +var_dump(rsort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +// testing rsort() function by supplying string object array, flag value = SORT_REGULAR +$temp_array = $unsorted_str_obj; +var_dump(rsort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing rsort() : object functionality *** + +-- Sort flag = default -- +bool(true) +array(4) { + [0]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + int(66) + ["private_class_value:private"]=> + int(44) + ["protected_class_value:protected"]=> + int(4) + } + [1]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + int(11) + ["private_class_value:private"]=> + int(33) + ["protected_class_value:protected"]=> + int(30) + } + [2]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + float(0.001) + ["private_class_value:private"]=> + float(99.5) + ["protected_class_value:protected"]=> + float(0.1) + } + [3]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + int(-88) + ["private_class_value:private"]=> + int(-5) + ["protected_class_value:protected"]=> + int(5) + } +} +bool(true) +array(4) { + [0]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value:private"]=> + string(1) "W" + ["protected_class_value:protected"]=> + string(1) "c" + } + [1]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(1) "t" + ["private_class_value:private"]=> + string(3) "eee" + ["protected_class_value:protected"]=> + string(3) "abb" + } + [2]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(2) "py" + ["private_class_value:private"]=> + string(2) "PY" + ["protected_class_value:protected"]=> + string(2) "pt" + } + [3]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value:private"]=> + string(3) "AXX" + ["protected_class_value:protected"]=> + string(3) "ass" + } +} + +-- Sort flag = SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + int(66) + ["private_class_value:private"]=> + int(44) + ["protected_class_value:protected"]=> + int(4) + } + [1]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + int(11) + ["private_class_value:private"]=> + int(33) + ["protected_class_value:protected"]=> + int(30) + } + [2]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + float(0.001) + ["private_class_value:private"]=> + float(99.5) + ["protected_class_value:protected"]=> + float(0.1) + } + [3]=> + object(for_integer_rsort)#%d (3) { + ["public_class_value"]=> + int(-88) + ["private_class_value:private"]=> + int(-5) + ["protected_class_value:protected"]=> + int(5) + } +} +bool(true) +array(4) { + [0]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value:private"]=> + string(1) "W" + ["protected_class_value:protected"]=> + string(1) "c" + } + [1]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(1) "t" + ["private_class_value:private"]=> + string(3) "eee" + ["protected_class_value:protected"]=> + string(3) "abb" + } + [2]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(2) "py" + ["private_class_value:private"]=> + string(2) "PY" + ["protected_class_value:protected"]=> + string(2) "pt" + } + [3]=> + object(for_string_rsort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value:private"]=> + string(3) "AXX" + ["protected_class_value:protected"]=> + string(3) "ass" + } +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation1.phpt b/ext/standard/tests/array/rsort_variation1.phpt new file mode 100644 index 0000000000..96dac90ae7 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation1.phpt @@ -0,0 +1,514 @@ +--TEST-- +Test rsort() function : usage variations - Pass different data types as $array_arg arg +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : variation *** +-- Iteration 1 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 2 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 3 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 4 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 5 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 6 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 7 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 8 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 9 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 10 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 11 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 12 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 13 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 14 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 15 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 16 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 17 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 18 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 19 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 20 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 21 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +-- Iteration 22 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 23 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 24 -- +Flag = default: + +Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Flag = SORT_REGULAR: + +Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Flag = SORT_NUMERIC: + +Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Flag = SORT_STRING: + +Warning: rsort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation10.phpt b/ext/standard/tests/array/rsort_variation10.phpt new file mode 100644 index 0000000000..ccf886b070 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation10.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test rsort() function : usage variations - Octal values +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- Sort flag = default -- +bool(true) +array(9) { + [0]=> + int(669) + [1]=> + int(506) + [2]=> + int(229) + [3]=> + int(209) + [4]=> + int(63) + [5]=> + int(54) + [6]=> + int(0) + [7]=> + int(-54) + [8]=> + int(-229) +} + +-- Sort flag = SORT_REGULAR -- +bool(true) +array(9) { + [0]=> + int(669) + [1]=> + int(506) + [2]=> + int(229) + [3]=> + int(209) + [4]=> + int(63) + [5]=> + int(54) + [6]=> + int(0) + [7]=> + int(-54) + [8]=> + int(-229) +} + +-- Sort flag = SORT_NUMERIC -- +bool(true) +array(9) { + [0]=> + int(669) + [1]=> + int(506) + [2]=> + int(229) + [3]=> + int(209) + [4]=> + int(63) + [5]=> + int(54) + [6]=> + int(0) + [7]=> + int(-54) + [8]=> + int(-229) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation11.phpt b/ext/standard/tests/array/rsort_variation11.phpt new file mode 100644 index 0000000000000000000000000000000000000000..83bbf84df02e7b71b893b42ddf85de71061f39eb GIT binary patch literal 2695 zcmeHIZENB{5Wdg(6@$n%k*p?Bd#$~;9IZVL-q9w>9iVfEpwHt=cNF&p62<&vTA+!T-WP_%Q=jFNHYa>aym&C zd|upp4m99W6f>DF$z2bI2m;THJJbg$)N*O3WT|s5Kf5 zpt7aee8bq=mI@HR%W5a+xn*m%=8KiEm8$1UslQ0vru=rn@>w^Q8Ky7*#55j9bU@8cu2?j;;sjVgv62`#leT-HawT z{qMJfZ#Vzx-iKYXcLZ~pX98R3{0t|p|NFXsF}lKGdq?LvXt1Y#4o#&?W%nG@JW=Gq zA3VcxaDRG+tC4n$a4Rl>b_wi4K*Q{|+c?7d8Ha|8eh|XC8zibChX#1jhFde+*ZX~8 z%WD&BxM8(9?Ki}9_XcUBw4CiSQo|XPoCMRijJ5)6z(!LjiPwW0dNfjGU>Qp})>zNR zCmIa>(pnwk*J_nY8tPUcJUALTVm_<@WTWSkpf44Og6V3LBO~AG2UI?OrQFfVp>2+2 zk#psCsD$It9W8SjOUvHBRRkFhd${lAPA{l)zS Du`RPf literal 0 HcmV?d00001 diff --git a/ext/standard/tests/array/rsort_variation2.phpt b/ext/standard/tests/array/rsort_variation2.phpt new file mode 100644 index 0000000000..2196a6494d --- /dev/null +++ b/ext/standard/tests/array/rsort_variation2.phpt @@ -0,0 +1,484 @@ +--TEST-- +Test rsort() function : usage variations - Pass different data types as $sort_flags arg +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- Iteration 1 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 2 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 3 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 4 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 5 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 6 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 7 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 8 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 9 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 10 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 11 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 12 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 13 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 14 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 15 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 16 -- + +Warning: rsort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} + +-- Iteration 17 -- + +Warning: rsort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} + +-- Iteration 18 -- + +Warning: rsort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} + +-- Iteration 19 -- + +Warning: rsort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} + +-- Iteration 20 -- + +Warning: rsort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} + +-- Iteration 21 -- + +Warning: rsort() expects parameter 2 to be long, object given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} + +-- Iteration 22 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 23 -- +bool(true) +array(5) { + [0]=> + int(5) + [1]=> + int(3) + [2]=> + int(2) + [3]=> + int(1) + [4]=> + int(1) +} + +-- Iteration 24 -- + +Warning: rsort() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(1) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation3.phpt b/ext/standard/tests/array/rsort_variation3.phpt new file mode 100644 index 0000000000..c0c11b5f05 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation3.phpt @@ -0,0 +1,321 @@ +--TEST-- +Test rsort() function : usage variations - numeric values +--FILE-- + SORT_REGULAR, "SORT_NUMERIC" => SORT_NUMERIC); + +$count = 1; + +// loop through to test rsort() with different arrays +foreach ($various_arrays as $array) { + echo "\n-- Iteration $count --\n"; + + echo "- With Defualt sort flag -\n"; + $temp_array = $array; + var_dump(rsort($temp_array) ); + var_dump($temp_array); + + // loop through $flag_value array and setting all possible flag values + foreach($flag_value as $key => $flag){ + echo "- Sort flag = $key -\n"; + $temp_array = $array; + var_dump(rsort($temp_array, $flag) ); + var_dump($temp_array); + } + $count++; +} + +echo "Done"; +?> + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- Iteration 1 -- +- With Defualt sort flag - +bool(true) +array(9) { + [0]=> + int(41) + [1]=> + int(31) + [2]=> + int(21) + [3]=> + int(11) + [4]=> + int(0) + [5]=> + int(-11) + [6]=> + int(-21) + [7]=> + int(-31) + [8]=> + int(-41) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(9) { + [0]=> + int(41) + [1]=> + int(31) + [2]=> + int(21) + [3]=> + int(11) + [4]=> + int(0) + [5]=> + int(-11) + [6]=> + int(-21) + [7]=> + int(-31) + [8]=> + int(-41) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(9) { + [0]=> + int(41) + [1]=> + int(31) + [2]=> + int(21) + [3]=> + int(11) + [4]=> + int(0) + [5]=> + int(-11) + [6]=> + int(-21) + [7]=> + int(-31) + [8]=> + int(-41) +} + +-- Iteration 2 -- +- With Defualt sort flag - +bool(true) +array(7) { + [0]=> + float(1050) + [1]=> + float(10.5) + [2]=> + float(0.5) + [3]=> + float(0.106) + [4]=> + float(0.01) + [5]=> + float(-0.1) + [6]=> + float(-10.5) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(7) { + [0]=> + float(1050) + [1]=> + float(10.5) + [2]=> + float(0.5) + [3]=> + float(0.106) + [4]=> + float(0.01) + [5]=> + float(-0.1) + [6]=> + float(-10.5) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(7) { + [0]=> + float(1050) + [1]=> + float(10.5) + [2]=> + float(0.5) + [3]=> + float(0.106) + [4]=> + float(0.01) + [5]=> + float(-0.1) + [6]=> + float(-10.5) +} + +-- Iteration 3 -- +- With Defualt sort flag - +bool(true) +array(11) { + [0]=> + int(33) + [1]=> + int(2) + [2]=> + float(0.106) + [3]=> + float(0.09) + [4]=> + float(0.0021) + [5]=> + float(0.0001) + [6]=> + int(0) + [7]=> + float(-0.01) + [8]=> + float(-0.106) + [9]=> + float(-0.9) + [10]=> + int(-1) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(11) { + [0]=> + int(33) + [1]=> + int(2) + [2]=> + float(0.106) + [3]=> + float(0.09) + [4]=> + float(0.0021) + [5]=> + float(0.0001) + [6]=> + int(0) + [7]=> + float(-0.01) + [8]=> + float(-0.106) + [9]=> + float(-0.9) + [10]=> + int(-1) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(11) { + [0]=> + int(33) + [1]=> + int(2) + [2]=> + float(0.106) + [3]=> + float(0.09) + [4]=> + float(0.0021) + [5]=> + float(0.0001) + [6]=> + int(0) + [7]=> + float(-0.01) + [8]=> + float(-0.106) + [9]=> + float(-0.9) + [10]=> + int(-1) +} + +-- Iteration 4 -- +- With Defualt sort flag - +bool(true) +array(7) { + [0]=> + float(2147483648) + [1]=> + int(2147483647) + [2]=> + int(0) + [3]=> + int(0) + [4]=> + int(-2147483647) + [5]=> + float(-2147483648) + [6]=> + float(-2147483649) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(7) { + [0]=> + float(2147483648) + [1]=> + int(2147483647) + [2]=> + int(0) + [3]=> + int(0) + [4]=> + int(-2147483647) + [5]=> + float(-2147483648) + [6]=> + float(-2147483649) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(7) { + [0]=> + float(2147483648) + [1]=> + int(2147483647) + [2]=> + int(0) + [3]=> + int(0) + [4]=> + int(-2147483647) + [5]=> + float(-2147483648) + [6]=> + float(-2147483649) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation4.phpt b/ext/standard/tests/array/rsort_variation4.phpt new file mode 100644 index 0000000000..abbed35bad --- /dev/null +++ b/ext/standard/tests/array/rsort_variation4.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test rsort() function : usage variations - referenced variables +--FILE-- + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- 'flag' value is defualt -- +bool(true) +array(3) { + [0]=> + &int(555) + [1]=> + &int(100) + [2]=> + &int(33) +} + +-- 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [0]=> + &int(555) + [1]=> + &int(100) + [2]=> + &int(33) +} + +-- 'flag' = SORT_NUMERIC -- +bool(true) +array(3) { + [0]=> + &int(555) + [1]=> + &int(100) + [2]=> + &int(33) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation5.phpt b/ext/standard/tests/array/rsort_variation5.phpt new file mode 100644 index 0000000000..eba6bc4201 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation5.phpt @@ -0,0 +1,221 @@ +--TEST-- +Test rsort() function : usage variations - String values +--FILE-- + 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 \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation6.phpt b/ext/standard/tests/array/rsort_variation6.phpt new file mode 100644 index 0000000000..559a1ebaf7 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation6.phpt @@ -0,0 +1,120 @@ +--TEST-- +Test rsort() function : usage variations - Hexadecimal vales +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- 'flag' value is defualt -- +bool(true) +array(11) { + [0]=> + int(4095) + [1]=> + int(682) + [2]=> + int(427) + [3]=> + int(427) + [4]=> + int(255) + [5]=> + int(255) + [6]=> + int(187) + [7]=> + int(15) + [8]=> + int(0) + [9]=> + int(-255) + [10]=> + int(-682) +} + +-- 'flag' value is SORT_REGULAR -- +bool(true) +array(11) { + [0]=> + int(4095) + [1]=> + int(682) + [2]=> + int(427) + [3]=> + int(427) + [4]=> + int(255) + [5]=> + int(255) + [6]=> + int(187) + [7]=> + int(15) + [8]=> + int(0) + [9]=> + int(-255) + [10]=> + int(-682) +} + +-- 'flag' value is SORT_NUMERIC -- +bool(true) +array(11) { + [0]=> + int(4095) + [1]=> + int(682) + [2]=> + int(427) + [3]=> + int(427) + [4]=> + int(255) + [5]=> + int(255) + [6]=> + int(187) + [7]=> + int(15) + [8]=> + int(0) + [9]=> + int(-255) + [10]=> + int(-682) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation7.phpt b/ext/standard/tests/array/rsort_variation7.phpt new file mode 100644 index 0000000000..a996bf6db3 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation7.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test rsort() function : usage variations - boolean values +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- 'flag' value is defualt -- +bool(true) +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + bool(false) + [3]=> + bool(false) +} + +-- 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + bool(false) + [3]=> + bool(false) +} + +-- 'flag' value is SORT_NUMERIC -- +bool(true) +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + bool(false) + [3]=> + bool(false) +} + +-- 'flag' value is SORT_STRING -- +bool(true) +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + bool(false) + [3]=> + bool(false) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation8.phpt b/ext/standard/tests/array/rsort_variation8.phpt new file mode 100644 index 0000000000..a4f94b5f0f --- /dev/null +++ b/ext/standard/tests/array/rsort_variation8.phpt @@ -0,0 +1,180 @@ +--TEST-- +Test rsort() function : usage variations - multi-dimensional arrays +--FILE-- + + +--EXPECTF-- +*** Testing rsort() : variation *** + +-- Iteration 1 -- + +-- 'flag' value is default -- +bool(true) +array(0) { +} + +-- 'flag' value is SORT_REGULAR -- +bool(true) +array(0) { +} + +-- Iteration 2 -- + +-- 'flag' value is default -- +bool(true) +array(1) { + [0]=> + array(0) { + } +} + +-- 'flag' value is SORT_REGULAR -- +bool(true) +array(1) { + [0]=> + array(0) { + } +} + +-- Iteration 3 -- + +-- 'flag' value is default -- +bool(true) +array(3) { + [0]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } + [1]=> + int(44) + [2]=> + int(11) +} + +-- 'flag' value is SORT_REGULAR -- +bool(true) +array(3) { + [0]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } + [1]=> + int(44) + [2]=> + int(11) +} + +-- Iteration 4 -- + +-- 'flag' value is default -- +bool(true) +array(4) { + [0]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } + [1]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [2]=> + array(1) { + [0]=> + int(11) + } + [3]=> + array(0) { + } +} + +-- 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } + [1]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [2]=> + array(1) { + [0]=> + int(11) + } + [3]=> + array(0) { + } +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/rsort_variation9.phpt b/ext/standard/tests/array/rsort_variation9.phpt new file mode 100644 index 0000000000..c08791df19 --- /dev/null +++ b/ext/standard/tests/array/rsort_variation9.phpt @@ -0,0 +1,259 @@ +--TEST-- +Test rsort() function : usage variations - mixed associative arrays +--FILE-- + 55, 6 => 66, 2 => 22, 3 => 33, 1 => 11), + + // two-dimensional assoc. and default key array + array("fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"), + "numbers" => array(1, 2, 3, 4, 5, 6), + "holes" => array("first", 5 => "second", "third")), + + // numeric assoc. and default key array + array(1, 1, 8 => 1, 4 => 1, 19, 3 => 13), + + // mixed assoc. array + array('bar' => 'baz', "foo" => 1), + + // assoc. only multi-dimensional array + array('a' => 1,'b' => array('e' => 2,'f' => 3),'c' => array('g' => 4),'d' => 5), +); + +$count = 1; + +// loop through to test rsort() with different arrays, +// to test the new keys for the elements in the sorted array +foreach ($various_arrays as $array) { + echo "\n-- Iteration $count --\n"; + + echo "-- Sort flag = default --\n"; + $temp_array = $array; + var_dump(rsort($temp_array) ); + var_dump($temp_array); + + echo "-- Sort flag = SORT_REGULAR --\n"; + $temp_array = $array; + var_dump(rsort($temp_array, SORT_REGULAR) ); + var_dump($temp_array); + $count++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing rsort() : variation *** + +-- Iteration 1 -- +-- Sort flag = default -- +bool(true) +array(5) { + [0]=> + int(66) + [1]=> + int(55) + [2]=> + int(33) + [3]=> + int(22) + [4]=> + int(11) +} +-- Sort flag = SORT_REGULAR -- +bool(true) +array(5) { + [0]=> + int(66) + [1]=> + int(55) + [2]=> + int(33) + [3]=> + int(22) + [4]=> + int(11) +} + +-- Iteration 2 -- +-- Sort flag = default -- +bool(true) +array(3) { + [0]=> + array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + } + [1]=> + array(3) { + [0]=> + string(5) "first" + [5]=> + string(6) "second" + [6]=> + string(5) "third" + } + [2]=> + array(3) { + ["a"]=> + string(6) "orange" + ["b"]=> + string(6) "banana" + ["c"]=> + string(5) "apple" + } +} +-- Sort flag = SORT_REGULAR -- +bool(true) +array(3) { + [0]=> + array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + } + [1]=> + array(3) { + [0]=> + string(5) "first" + [5]=> + string(6) "second" + [6]=> + string(5) "third" + } + [2]=> + array(3) { + ["a"]=> + string(6) "orange" + ["b"]=> + string(6) "banana" + ["c"]=> + string(5) "apple" + } +} + +-- Iteration 3 -- +-- Sort flag = default -- +bool(true) +array(6) { + [0]=> + int(19) + [1]=> + int(13) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) +} +-- Sort flag = SORT_REGULAR -- +bool(true) +array(6) { + [0]=> + int(19) + [1]=> + int(13) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) +} + +-- Iteration 4 -- +-- Sort flag = default -- +bool(true) +array(2) { + [0]=> + int(1) + [1]=> + string(3) "baz" +} +-- Sort flag = SORT_REGULAR -- +bool(true) +array(2) { + [0]=> + int(1) + [1]=> + string(3) "baz" +} + +-- Iteration 5 -- +-- Sort flag = default -- +bool(true) +array(4) { + [0]=> + array(2) { + ["e"]=> + int(2) + ["f"]=> + int(3) + } + [1]=> + array(1) { + ["g"]=> + int(4) + } + [2]=> + int(5) + [3]=> + int(1) +} +-- Sort flag = SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + array(2) { + ["e"]=> + int(2) + ["f"]=> + int(3) + } + [1]=> + array(1) { + ["g"]=> + int(4) + } + [2]=> + int(5) + [3]=> + int(1) +} +Done \ No newline at end of file -- 2.50.1