From c9b73bf23d583be1538d9ae84cbacf51eeeba421 Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Mon, 5 Nov 2007 15:30:49 +0000 Subject: [PATCH] New testcases for sort() function --- ext/standard/tests/array/sort_basic.phpt | 134 ++++++ ext/standard/tests/array/sort_error.phpt | 79 ++++ ext/standard/tests/array/sort_object1.phpt | 242 +++++++++++ ext/standard/tests/array/sort_object2.phpt | 256 +++++++++++ ext/standard/tests/array/sort_variation1.phpt | 398 ++++++++++++++++++ .../tests/array/sort_variation10.phpt | 112 +++++ .../tests/array/sort_variation11.phpt | Bin 0 -> 3144 bytes ext/standard/tests/array/sort_variation2.phpt | 311 ++++++++++++++ ext/standard/tests/array/sort_variation3.phpt | 328 +++++++++++++++ ext/standard/tests/array/sort_variation4.phpt | 79 ++++ ext/standard/tests/array/sort_variation5.phpt | 236 +++++++++++ ext/standard/tests/array/sort_variation6.phpt | 123 ++++++ ext/standard/tests/array/sort_variation7.phpt | 98 +++++ ext/standard/tests/array/sort_variation8.phpt | 178 ++++++++ ext/standard/tests/array/sort_variation9.phpt | 259 ++++++++++++ 15 files changed, 2833 insertions(+) create mode 100644 ext/standard/tests/array/sort_basic.phpt create mode 100644 ext/standard/tests/array/sort_error.phpt create mode 100644 ext/standard/tests/array/sort_object1.phpt create mode 100644 ext/standard/tests/array/sort_object2.phpt create mode 100644 ext/standard/tests/array/sort_variation1.phpt create mode 100644 ext/standard/tests/array/sort_variation10.phpt create mode 100644 ext/standard/tests/array/sort_variation11.phpt create mode 100644 ext/standard/tests/array/sort_variation2.phpt create mode 100644 ext/standard/tests/array/sort_variation3.phpt create mode 100644 ext/standard/tests/array/sort_variation4.phpt create mode 100644 ext/standard/tests/array/sort_variation5.phpt create mode 100644 ext/standard/tests/array/sort_variation6.phpt create mode 100644 ext/standard/tests/array/sort_variation7.phpt create mode 100644 ext/standard/tests/array/sort_variation8.phpt create mode 100644 ext/standard/tests/array/sort_variation9.phpt diff --git a/ext/standard/tests/array/sort_basic.phpt b/ext/standard/tests/array/sort_basic.phpt new file mode 100644 index 00000000000..3cf653f2089 --- /dev/null +++ b/ext/standard/tests/array/sort_basic.phpt @@ -0,0 +1,134 @@ +--TEST-- +Test sort() 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 sort() by supplying string array, 'flag' value is defualt --\n"; +$temp_array = $unsorted_strings; +var_dump( sort($temp_array) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing sort() by supplying numeric array, 'flag' value is defualt --\n"; +$temp_array = $unsorted_numerics; +var_dump( sort($temp_array) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing sort() by supplying string array, 'flag' = SORT_REGULAR --\n"; +$temp_array = $unsorted_strings; +var_dump( sort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing sort() by supplying numeric array, 'flag' = SORT_REGULAR --\n"; +$temp_array = $unsorted_numerics; +var_dump( sort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing sort() by supplying string array, 'flag' = SORT_STRING --\n"; +$temp_array = $unsorted_strings; +var_dump( sort($temp_array, SORT_STRING) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing sort() by supplying numeric array, 'flag' = SORT_NUMERIC --\n"; +$temp_array = $unsorted_numerics; +var_dump( sort($temp_array, SORT_NUMERIC) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing sort() : basic functionality *** + +-- Testing sort() by supplying string array, 'flag' value is defualt -- +bool(true) +array(3) { + [0]=> + string(6) "banana" + [1]=> + string(5) "lemon" + [2]=> + string(6) "orange" +} + +-- Testing sort() by supplying numeric array, 'flag' value is defualt -- +bool(true) +array(4) { + [0]=> + int(22) + [1]=> + int(33) + [2]=> + int(100) + [3]=> + int(555) +} + +-- Testing sort() by supplying string array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [0]=> + string(6) "banana" + [1]=> + string(5) "lemon" + [2]=> + string(6) "orange" +} + +-- Testing sort() by supplying numeric array, 'flag' = SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + int(22) + [1]=> + int(33) + [2]=> + int(100) + [3]=> + int(555) +} + +-- Testing sort() by supplying string array, 'flag' = SORT_STRING -- +bool(true) +array(3) { + [0]=> + string(6) "banana" + [1]=> + string(5) "lemon" + [2]=> + string(6) "orange" +} + +-- Testing sort() by supplying numeric array, 'flag' = SORT_NUMERIC -- +bool(true) +array(4) { + [0]=> + int(22) + [1]=> + int(33) + [2]=> + int(100) + [3]=> + int(555) +} +Done diff --git a/ext/standard/tests/array/sort_error.phpt b/ext/standard/tests/array/sort_error.phpt new file mode 100644 index 00000000000..4864ef33df2 --- /dev/null +++ b/ext/standard/tests/array/sort_error.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test sort() function : error conditions +--FILE-- + SORT_REGULAR, "SORT_STRING" => SORT_STRING, "SORT_NUMERIC" => SORT_NUMERIC); +$extra_arg = 10; + +// loop through $flag_value array and setting all possible flag values +foreach($flag_value as $key => $flag){ + echo "\nSort flag = $key\n"; + var_dump( sort($array_arg,$flag, $extra_arg) ); + + // dump the input array to ensure that it wasn't changed + var_dump($array_arg); +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing sort() : error conditions *** + +-- Testing sort() function with Zero arguments -- + +Warning: sort() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing sort() function with more than expected no. of arguments -- + +Sort flag = SORT_REGULAR + +Warning: sort() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} + +Sort flag = SORT_STRING + +Warning: sort() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} + +Sort flag = SORT_NUMERIC + +Warning: sort() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +Done diff --git a/ext/standard/tests/array/sort_object1.phpt b/ext/standard/tests/array/sort_object1.phpt new file mode 100644 index 00000000000..caa9c8dbb64 --- /dev/null +++ b/ext/standard/tests/array/sort_object1.phpt @@ -0,0 +1,242 @@ +--TEST-- +Test sort() function : object functionality - sorting objects, 'sort_flags' as default/SORT_REGULAR +--FILE-- +class_value = $value; + } + +} + +// class declaration for string objects +class for_string_sort +{ + 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_sort(11), new for_integer_sort(66), + new for_integer_sort(23), new for_integer_sort(-5), + new for_integer_sort(0.001), new for_integer_sort(0) +); + +// array of string objects +$unsorted_str_obj = array ( + new for_string_sort("axx"), new for_string_sort("t"), + new for_string_sort("w"), new for_string_sort("py"), + new for_string_sort("apple"), new for_string_sort("Orange"), + new for_string_sort("Lemon"), new for_string_sort("aPPle") +); + + +echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is defualt --\n"; + +// testing sort() function by supplying integer object array, flag value is defualt +$temp_array = $unsorted_int_obj; +var_dump(sort($temp_array) ); +var_dump($temp_array); + +// testing sort() function by supplying string object array, flag value is defualt +$temp_array = $unsorted_str_obj; +var_dump(sort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n"; +// testing sort() function by supplying integer object array, flag value = SORT_REGULAR +$temp_array = $unsorted_int_obj; +var_dump(sort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +// testing sort() function by supplying string object array, flag value = SORT_REGULAR +$temp_array = $unsorted_str_obj; +var_dump(sort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing sort() : object functionality *** + +-- Testing sort() by supplying various object arrays, 'flag' value is defualt -- +bool(true) +array(6) { + [0]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(-5) + } + [1]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(0) + } + [2]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + float(0.001) + } + [3]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(11) + } + [4]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(23) + } + [5]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(66) + } +} +bool(true) +array(8) { + [0]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } + [1]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + [2]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + [3]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + [4]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + [5]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + [6]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + [7]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(1) "w" + } +} + +-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR -- +bool(true) +array(6) { + [0]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(-5) + } + [1]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(0) + } + [2]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + float(0.001) + } + [3]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(11) + } + [4]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(23) + } + [5]=> + object(for_integer_sort)#%d (1) { + ["class_value"]=> + int(66) + } +} +bool(true) +array(8) { + [0]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } + [1]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + [2]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + [3]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + [4]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + [5]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + [6]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + [7]=> + object(for_string_sort)#%d (1) { + ["class_value"]=> + string(1) "w" + } +} +Done diff --git a/ext/standard/tests/array/sort_object2.phpt b/ext/standard/tests/array/sort_object2.phpt new file mode 100644 index 00000000000..47856e002b7 --- /dev/null +++ b/ext/standard/tests/array/sort_object2.phpt @@ -0,0 +1,256 @@ +--TEST-- +Test sort() function : object functionality - sorting objects with diff. accessiblity of member vars +--FILE-- +public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } +} + +// class declaration for string objects +class for_string_sort +{ + 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_sort(11,33,30), + new for_integer_sort(66,44,4), + new for_integer_sort(-88,-5,5), + new for_integer_sort(0.001,99.5,0.1) +); + +// array of string objects +$unsorted_str_obj = array ( + new for_string_sort("axx","AXX","ass"), + new for_string_sort("t","eee","abb"), + new for_string_sort("w","W", "c"), + new for_string_sort("py","PY", "pt"), +); + + +echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is defualt --\n"; + +// testing sort() function by supplying integer object array, flag value is defualt +$temp_array = $unsorted_int_obj; +var_dump(sort($temp_array) ); +var_dump($temp_array); + +// testing sort() function by supplying string object array, flag value is defualt +$temp_array = $unsorted_str_obj; +var_dump(sort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n"; +// testing sort() function by supplying integer object array, flag value = SORT_REGULAR +$temp_array = $unsorted_int_obj; +var_dump(sort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +// testing sort() function by supplying string object array, flag value = SORT_REGULAR +$temp_array = $unsorted_str_obj; +var_dump(sort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing sort() : object functionality *** + +-- Testing sort() by supplying various object arrays, 'flag' value is defualt -- +bool(true) +array(4) { + [0]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + int(-88) + ["private_class_value":"for_integer_sort":private]=> + int(-5) + ["protected_class_value":protected]=> + int(5) + } + [1]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + float(0.001) + ["private_class_value":"for_integer_sort":private]=> + float(99.5) + ["protected_class_value":protected]=> + float(0.1) + } + [2]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + int(11) + ["private_class_value":"for_integer_sort":private]=> + int(33) + ["protected_class_value":protected]=> + int(30) + } + [3]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + int(66) + ["private_class_value":"for_integer_sort":private]=> + int(44) + ["protected_class_value":protected]=> + int(4) + } +} +bool(true) +array(4) { + [0]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value":"for_string_sort":private]=> + string(3) "AXX" + ["protected_class_value":protected]=> + string(3) "ass" + } + [1]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(2) "py" + ["private_class_value":"for_string_sort":private]=> + string(2) "PY" + ["protected_class_value":protected]=> + string(2) "pt" + } + [2]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(1) "t" + ["private_class_value":"for_string_sort":private]=> + string(3) "eee" + ["protected_class_value":protected]=> + string(3) "abb" + } + [3]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value":"for_string_sort":private]=> + string(1) "W" + ["protected_class_value":protected]=> + string(1) "c" + } +} + +-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + int(-88) + ["private_class_value":"for_integer_sort":private]=> + int(-5) + ["protected_class_value":protected]=> + int(5) + } + [1]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + float(0.001) + ["private_class_value":"for_integer_sort":private]=> + float(99.5) + ["protected_class_value":protected]=> + float(0.1) + } + [2]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + int(11) + ["private_class_value":"for_integer_sort":private]=> + int(33) + ["protected_class_value":protected]=> + int(30) + } + [3]=> + object(for_integer_sort)#%d (3) { + ["public_class_value"]=> + int(66) + ["private_class_value":"for_integer_sort":private]=> + int(44) + ["protected_class_value":protected]=> + int(4) + } +} +bool(true) +array(4) { + [0]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value":"for_string_sort":private]=> + string(3) "AXX" + ["protected_class_value":protected]=> + string(3) "ass" + } + [1]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(2) "py" + ["private_class_value":"for_string_sort":private]=> + string(2) "PY" + ["protected_class_value":protected]=> + string(2) "pt" + } + [2]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(1) "t" + ["private_class_value":"for_string_sort":private]=> + string(3) "eee" + ["protected_class_value":protected]=> + string(3) "abb" + } + [3]=> + object(for_string_sort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value":"for_string_sort":private]=> + string(1) "W" + ["protected_class_value":protected]=> + string(1) "c" + } +} +Done diff --git a/ext/standard/tests/array/sort_variation1.phpt b/ext/standard/tests/array/sort_variation1.phpt new file mode 100644 index 00000000000..f6991bdf67b --- /dev/null +++ b/ext/standard/tests/array/sort_variation1.phpt @@ -0,0 +1,398 @@ +--TEST-- +Test sort() function : usage variations - unexpected values for 'array_arg' argument +--FILE-- + +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying different unexpected values for 'array' argument -- + +-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING -- +-- Iteration 1 -- + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 11 -- + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 12 -- + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 14 -- + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: sort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +-- Iteration 21 -- + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 23 -- + +Warning: sort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/sort_variation10.phpt b/ext/standard/tests/array/sort_variation10.phpt new file mode 100644 index 00000000000..0a5a58044ae --- /dev/null +++ b/ext/standard/tests/array/sort_variation10.phpt @@ -0,0 +1,112 @@ +--TEST-- +Test sort() function : usage variations - sort octal values +--FILE-- + +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying octal value array, 'flag' value is defualt -- +bool(true) +array(9) { + [0]=> + int(-229) + [1]=> + int(-54) + [2]=> + int(0) + [3]=> + int(54) + [4]=> + int(63) + [5]=> + int(209) + [6]=> + int(229) + [7]=> + int(506) + [8]=> + int(669) +} + +-- Testing sort() by supplying octal value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(9) { + [0]=> + int(-229) + [1]=> + int(-54) + [2]=> + int(0) + [3]=> + int(54) + [4]=> + int(63) + [5]=> + int(209) + [6]=> + int(229) + [7]=> + int(506) + [8]=> + int(669) +} + +-- Testing sort() by supplying octal value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(9) { + [0]=> + int(-229) + [1]=> + int(-54) + [2]=> + int(0) + [3]=> + int(54) + [4]=> + int(63) + [5]=> + int(209) + [6]=> + int(229) + [7]=> + int(506) + [8]=> + int(669) +} +Done diff --git a/ext/standard/tests/array/sort_variation11.phpt b/ext/standard/tests/array/sort_variation11.phpt new file mode 100644 index 0000000000000000000000000000000000000000..56583d2089a0746e2bf0475598165c1dbeb9803f GIT binary patch literal 3144 zcmeHJZEM>w5Z-71iX)WO4pv^Aq+7eSW31U23u|dJ7_=iOv62`R%gFNDF#6wjCn=e; zwQR6{Yzwx0Z@TBXmzJ^d@N&#pFczhOQfU)LFt75N$y5$UP?dZk;5*kDCrJs+8o?^N z6)DPPCCV7~$#F85e6bI_gjCEcE=~LL>|#8*7=HLNdV2xk*(Wdx<~);RqeWRs16c`G zUTBeunc-6@qJXjYA4fyX==GaoSp@ASoNHy2Sr-B@p{Y{Rr4Rzwny=yco_k-#kmUyU zwz-twAPS%fr=pzctf2glV7$aDw*bku1fIK4EePPZpP>{hk)zE`CM8UTHOv=?eXi9C zq`D#A5Z5wWEa`Z&6gilkOO^5$1DV{1!P97O30O7aVgg}Q!!gAXf&Hmpf;*ydrt$Q)pg!@h49*c<{#`?NE6ps zaO_cqSQpDo7{yd0cXrQSF9tS<;Q&=m((P`KNkYoO_B(+2UUsSNxA?e4u67+6RgwJ0_BRq5K$)~dvH680m@knre+v(KbXt2K@ zgTW{=-?_s|msL^7^}UtGXl~vtRWwI_>VPrJ?;e(^m{>-T#~of@ z1vt=?v|1IRo%ot55>(UH6_1+h&Sv&BJ3-@XBwf$>DzN|?d3N$_33E0DXXof5T56VI4 z*brS0i-3BGhvO6NVt~GL_o!-$fm7^4>!XLAS9|9!KBSlC)@nRNACA22EL)w&ySZwk zd`1@b;X-%9h1PeW5qN nJy(vcyWs9IhOoXkaBDtI;?>h6K22gs|1Z_2`)`v-e^7&;PbFB0 literal 0 HcmV?d00001 diff --git a/ext/standard/tests/array/sort_variation2.phpt b/ext/standard/tests/array/sort_variation2.phpt new file mode 100644 index 00000000000..4304ecb7674 --- /dev/null +++ b/ext/standard/tests/array/sort_variation2.phpt @@ -0,0 +1,311 @@ +--TEST-- +Test sort() function : usage variations - unexpected values for 'sort_flags' argument +--FILE-- + +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying different unexpected values for 'flag' argument -- +-- Iteration 1 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 2 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 3 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 4 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 5 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 6 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 7 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 8 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 9 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 10 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 11 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 12 -- +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(10) + [2]=> + int(45) +} +-- Iteration 13 -- + +Warning: sort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 14 -- + +Warning: sort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 15 -- + +Warning: sort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 16 -- + +Warning: sort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 17 -- + +Warning: sort() expects parameter 2 to be long, object given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 18 -- + +Warning: sort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 19 -- + +Warning: sort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +-- Iteration 20 -- + +Warning: sort() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +array(3) { + [0]=> + int(10) + [1]=> + int(2) + [2]=> + int(45) +} +Done diff --git a/ext/standard/tests/array/sort_variation3.phpt b/ext/standard/tests/array/sort_variation3.phpt new file mode 100644 index 00000000000..914e7e5649f --- /dev/null +++ b/ext/standard/tests/array/sort_variation3.phpt @@ -0,0 +1,328 @@ +--TEST-- +Test sort() function : usage variations - sort integer/float values +--FILE-- + SORT_REGULAR, "SORT_NUMERIC" => SORT_NUMERIC); + +$count = 1; +echo "\n-- Testing sort() by supplying various integer/float arrays --\n"; + +// loop through to test sort() with different arrays +foreach ($various_arrays as $array) { + echo "\n-- Iteration $count --\n"; + + echo "- With Defualt sort flag -\n"; + $temp_array = $array; + var_dump(sort($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(sort($temp_array, $flag) ); + var_dump($temp_array); + } + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying various integer/float arrays -- + +-- 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(-10.5) + [1]=> + float(-0.1) + [2]=> + float(0.01) + [3]=> + float(0.106) + [4]=> + float(0.5) + [5]=> + float(10.5) + [6]=> + float(1050) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(7) { + [0]=> + float(-10.5) + [1]=> + float(-0.1) + [2]=> + float(0.01) + [3]=> + float(0.106) + [4]=> + float(0.5) + [5]=> + float(10.5) + [6]=> + float(1050) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(7) { + [0]=> + float(-10.5) + [1]=> + float(-0.1) + [2]=> + float(0.01) + [3]=> + float(0.106) + [4]=> + float(0.5) + [5]=> + float(10.5) + [6]=> + float(1050) +} + +-- Iteration 3 -- +- With Defualt sort flag - +bool(true) +array(11) { + [0]=> + int(-1) + [1]=> + float(-0.9) + [2]=> + float(-0.106) + [3]=> + float(-0.01) + [4]=> + int(0) + [5]=> + float(0.0001) + [6]=> + float(0.0021) + [7]=> + float(0.09) + [8]=> + float(0.106) + [9]=> + int(2) + [10]=> + int(33) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(11) { + [0]=> + int(-1) + [1]=> + float(-0.9) + [2]=> + float(-0.106) + [3]=> + float(-0.01) + [4]=> + int(0) + [5]=> + float(0.0001) + [6]=> + float(0.0021) + [7]=> + float(0.09) + [8]=> + float(0.106) + [9]=> + int(2) + [10]=> + int(33) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(11) { + [0]=> + int(-1) + [1]=> + float(-0.9) + [2]=> + float(-0.106) + [3]=> + float(-0.01) + [4]=> + int(0) + [5]=> + float(0.0001) + [6]=> + float(0.0021) + [7]=> + float(0.09) + [8]=> + float(0.106) + [9]=> + int(2) + [10]=> + int(33) +} + +-- Iteration 4 -- +- With Defualt sort flag - +bool(true) +array(7) { + [0]=> + float(-2147483649) + [1]=> + float(-2147483648) + [2]=> + int(-2147483647) + [3]=> + int(0) + [4]=> + int(0) + [5]=> + int(2147483647) + [6]=> + float(2147483648) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(7) { + [0]=> + float(-2147483649) + [1]=> + float(-2147483648) + [2]=> + int(-2147483647) + [3]=> + int(0) + [4]=> + int(0) + [5]=> + int(2147483647) + [6]=> + float(2147483648) +} +- Sort flag = SORT_NUMERIC - +bool(true) +array(7) { + [0]=> + float(-2147483649) + [1]=> + float(-2147483648) + [2]=> + int(-2147483647) + [3]=> + int(0) + [4]=> + int(0) + [5]=> + int(2147483647) + [6]=> + float(2147483648) +} +Done diff --git a/ext/standard/tests/array/sort_variation4.phpt b/ext/standard/tests/array/sort_variation4.phpt new file mode 100644 index 00000000000..82e3d9708f3 --- /dev/null +++ b/ext/standard/tests/array/sort_variation4.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test sort() function : usage variations - sort reference values +--FILE-- + +--EXPECTF-- +*** Testing sort() :usage variations *** + +-- Testing sort() by supplying reference variable array, 'flag' value is defualt -- +bool(true) +array(3) { + [0]=> + &int(33) + [1]=> + &int(100) + [2]=> + &int(555) +} + +-- Testing sort() by supplying reference variable array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [0]=> + &int(33) + [1]=> + &int(100) + [2]=> + &int(555) +} + +-- Testing sort() by supplying reference variable array, 'flag' = SORT_NUMERIC -- +bool(true) +array(3) { + [0]=> + &int(33) + [1]=> + &int(100) + [2]=> + &int(555) +} +Done diff --git a/ext/standard/tests/array/sort_variation5.phpt b/ext/standard/tests/array/sort_variation5.phpt new file mode 100644 index 00000000000..0ba53e3b341 --- /dev/null +++ b/ext/standard/tests/array/sort_variation5.phpt @@ -0,0 +1,236 @@ +--TEST-- +Test sort() function : usage variations - sort strings +--FILE-- + SORT_REGULAR, "SORT_STRING" => SORT_STRING); + +$count = 1; +echo "\n-- Testing sort() by supplying various string arrays --\n"; + +// loop through to test sort() with different arrays +foreach ($various_arrays as $array) { + echo "\n-- Iteration $count --\n"; + + echo "- With Default sort flag -\n"; + $temp_array = $array; + var_dump(sort($temp_array) ); // expecting : bool(true) + 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(sort($temp_array, $flag) ); // expecting : bool(true) + var_dump($temp_array); + } + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying various string arrays -- + +-- Iteration 1 -- +- With Default sort flag - +bool(true) +array(12) { + [0]=> + NULL + [1]=> + NULL + [2]=> + string(1) " " + [3]=> + string(1) " +" + [4]=> + string(1) " " + [5]=> + string(1) " " + [6]=> + string(1) " +" + [7]=> + string(2) "\a" + [8]=> + string(3) "\cx" + [9]=> + string(4) "\ddd" + [10]=> + string(2) "\e" + [11]=> + string(4) "\xhh" +} +- Sort flag = SORT_REGULAR - +bool(true) +array(12) { + [0]=> + NULL + [1]=> + NULL + [2]=> + string(1) " " + [3]=> + string(1) " +" + [4]=> + string(1) " " + [5]=> + string(1) " " + [6]=> + string(1) " +" + [7]=> + string(2) "\a" + [8]=> + string(3) "\cx" + [9]=> + string(4) "\ddd" + [10]=> + string(2) "\e" + [11]=> + string(4) "\xhh" +} +- Sort flag = SORT_STRING - +bool(true) +array(12) { + [0]=> + NULL + [1]=> + NULL + [2]=> + string(1) " " + [3]=> + string(1) " +" + [4]=> + string(1) " " + [5]=> + string(1) " " + [6]=> + string(1) " +" + [7]=> + string(2) "\a" + [8]=> + string(3) "\cx" + [9]=> + string(4) "\ddd" + [10]=> + string(2) "\e" + [11]=> + string(4) "\xhh" +} + +-- Iteration 2 -- +- With Default sort flag - +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +- Sort flag = SORT_REGULAR - +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +- Sort flag = SORT_STRING - +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +Done diff --git a/ext/standard/tests/array/sort_variation6.phpt b/ext/standard/tests/array/sort_variation6.phpt new file mode 100644 index 00000000000..7a93f0e5fe1 --- /dev/null +++ b/ext/standard/tests/array/sort_variation6.phpt @@ -0,0 +1,123 @@ +--TEST-- +Test sort() function : usage variations - sort hexadecimal values +--FILE-- + +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying hexadecimal value array, 'flag' value is defualt -- +bool(true) +array(11) { + [0]=> + int(-682) + [1]=> + int(-255) + [2]=> + int(0) + [3]=> + int(15) + [4]=> + int(187) + [5]=> + int(255) + [6]=> + int(255) + [7]=> + int(427) + [8]=> + int(427) + [9]=> + int(682) + [10]=> + int(4095) +} + +-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(11) { + [0]=> + int(-682) + [1]=> + int(-255) + [2]=> + int(0) + [3]=> + int(15) + [4]=> + int(187) + [5]=> + int(255) + [6]=> + int(255) + [7]=> + int(427) + [8]=> + int(427) + [9]=> + int(682) + [10]=> + int(4095) +} + +-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(11) { + [0]=> + int(-682) + [1]=> + int(-255) + [2]=> + int(0) + [3]=> + int(15) + [4]=> + int(187) + [5]=> + int(255) + [6]=> + int(255) + [7]=> + int(427) + [8]=> + int(427) + [9]=> + int(682) + [10]=> + int(4095) +} +Done diff --git a/ext/standard/tests/array/sort_variation7.phpt b/ext/standard/tests/array/sort_variation7.phpt new file mode 100644 index 00000000000..19d888a76a6 --- /dev/null +++ b/ext/standard/tests/array/sort_variation7.phpt @@ -0,0 +1,98 @@ +--TEST-- +Test sort() function : usage variations - sort boolean values +--FILE-- + +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying bool value array, 'flag' value is defualt -- +bool(true) +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing sort() by supplying bool value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing sort() by supplying bool value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing sort() by supplying bool value array, 'flag' value is SORT_STRING -- +bool(true) +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + bool(true) + [3]=> + bool(true) +} +Done diff --git a/ext/standard/tests/array/sort_variation8.phpt b/ext/standard/tests/array/sort_variation8.phpt new file mode 100644 index 00000000000..9a330313f9e --- /dev/null +++ b/ext/standard/tests/array/sort_variation8.phpt @@ -0,0 +1,178 @@ +--TEST-- +Test sort() function : usage variations - sort array with diff. sub arrays, 'sort_flags' as defualt/SORT_REGULAR +--FILE-- + +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying various arrays containing sub arrays -- + +-- Iteration 1 -- +- With Defualt sort flag - +bool(true) +array(0) { +} +- Sort flag = SORT_REGULAR - +bool(true) +array(0) { +} + +-- Iteration 2 -- +- With Defualt sort flag - +bool(true) +array(1) { + [0]=> + array(0) { + } +} +- Sort flag = SORT_REGULAR - +bool(true) +array(1) { + [0]=> + array(0) { + } +} + +-- Iteration 3 -- +- With Defualt sort flag - +bool(true) +array(3) { + [0]=> + int(11) + [1]=> + int(44) + [2]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } +} +- Sort flag = SORT_REGULAR - +bool(true) +array(3) { + [0]=> + int(11) + [1]=> + int(44) + [2]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } +} + +-- Iteration 4 -- +- With Defualt sort flag - +bool(true) +array(4) { + [0]=> + array(0) { + } + [1]=> + array(1) { + [0]=> + int(11) + } + [2]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [3]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } +} +- Sort flag = SORT_REGULAR - +bool(true) +array(4) { + [0]=> + array(0) { + } + [1]=> + array(1) { + [0]=> + int(11) + } + [2]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [3]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } +} +Done diff --git a/ext/standard/tests/array/sort_variation9.phpt b/ext/standard/tests/array/sort_variation9.phpt new file mode 100644 index 00000000000..faab1666c4b --- /dev/null +++ b/ext/standard/tests/array/sort_variation9.phpt @@ -0,0 +1,259 @@ +--TEST-- +Test sort() function : usage variations - sort diff. associative arrays, 'sort_flags' as defualt/SORT_REGULAR +--FILE-- + 55, 6 => 66, 2 => 22, 3 => 33, 1 => 11), + array ("fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"), + "numbers" => array(1, 2, 3, 4, 5, 6), + "holes" => array("first", 5 => "second", "third") + ), + array(1, 1, 8 => 1, 4 => 1, 19, 3 => 13), + array('bar' => 'baz', "foo" => 1), + array('a' => 1,'b' => array('e' => 2,'f' => 3),'c' => array('g' => 4),'d' => 5), +); + +$count = 1; +echo "\n-- Testing sort() by supplying various arrays with key values --\n"; + +// loop through to test sort() 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 "- With Defualt sort flag -\n"; + $temp_array = $array; + var_dump(sort($temp_array) ); + var_dump($temp_array); + + echo "- Sort flag = SORT_REGULAR -\n"; + $temp_array = $array; + var_dump(sort($temp_array, SORT_REGULAR) ); + var_dump($temp_array); + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing sort() : usage variations *** + +-- Testing sort() by supplying various arrays with key values -- + +-- Iteration 1 -- +- With Defualt sort flag - +bool(true) +array(5) { + [0]=> + int(11) + [1]=> + int(22) + [2]=> + int(33) + [3]=> + int(55) + [4]=> + int(66) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(5) { + [0]=> + int(11) + [1]=> + int(22) + [2]=> + int(33) + [3]=> + int(55) + [4]=> + int(66) +} + +-- Iteration 2 -- +- With Defualt sort flag - +bool(true) +array(3) { + [0]=> + array(3) { + [0]=> + string(5) "first" + [5]=> + string(6) "second" + [6]=> + string(5) "third" + } + [1]=> + array(3) { + ["a"]=> + string(6) "orange" + ["b"]=> + string(6) "banana" + ["c"]=> + string(5) "apple" + } + [2]=> + array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + } +} +- Sort flag = SORT_REGULAR - +bool(true) +array(3) { + [0]=> + array(3) { + [0]=> + string(5) "first" + [5]=> + string(6) "second" + [6]=> + string(5) "third" + } + [1]=> + array(3) { + ["a"]=> + string(6) "orange" + ["b"]=> + string(6) "banana" + ["c"]=> + string(5) "apple" + } + [2]=> + array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + } +} + +-- Iteration 3 -- +- With Defualt sort flag - +bool(true) +array(6) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(13) + [5]=> + int(19) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(6) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(13) + [5]=> + int(19) +} + +-- Iteration 4 -- +- With Defualt sort flag - +bool(true) +array(2) { + [0]=> + string(3) "baz" + [1]=> + int(1) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(2) { + [0]=> + string(3) "baz" + [1]=> + int(1) +} + +-- Iteration 5 -- +- With Defualt sort flag - +bool(true) +array(4) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + array(1) { + ["g"]=> + int(4) + } + [3]=> + array(2) { + ["e"]=> + int(2) + ["f"]=> + int(3) + } +} +- Sort flag = SORT_REGULAR - +bool(true) +array(4) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + array(1) { + ["g"]=> + int(4) + } + [3]=> + array(2) { + ["e"]=> + int(2) + ["f"]=> + int(3) + } +} +Done