From: Raghubansh Kumar Date: Mon, 5 Nov 2007 15:17:10 +0000 (+0000) Subject: New testcases for sort() function X-Git-Tag: RELEASE_2_0_0a1~1463 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=deb8a46c7bbf7ed6a06b3b09f665cb34227c61b9;p=php New testcases for sort() function --- diff --git a/ext/standard/tests/array/sort_basic.phpt b/ext/standard/tests/array/sort_basic.phpt new file mode 100644 index 0000000000..3e36dbd072 --- /dev/null +++ b/ext/standard/tests/array/sort_basic.phpt @@ -0,0 +1,209 @@ +--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 +--UEXPECTF-- +*** Testing sort() : basic functionality *** + +-- Testing sort() by supplying string array, 'flag' value is defualt -- +bool(true) +array(3) { + [0]=> + unicode(6) "banana" + [1]=> + unicode(5) "lemon" + [2]=> + unicode(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]=> + unicode(6) "banana" + [1]=> + unicode(5) "lemon" + [2]=> + unicode(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]=> + unicode(6) "banana" + [1]=> + unicode(5) "lemon" + [2]=> + unicode(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 0000000000..f3ea722c8b --- /dev/null +++ b/ext/standard/tests/array/sort_error.phpt @@ -0,0 +1,122 @@ +--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 +--UEXPECTF-- +*** 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 0000000000..6a22ebe9e3 --- /dev/null +++ b/ext/standard/tests/array/sort_object1.phpt @@ -0,0 +1,400 @@ +--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 +--UEXPECTF-- +*** 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) { + [u"class_value"]=> + int(-5) + } + [1]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(0) + } + [2]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + float(0.001) + } + [3]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(11) + } + [4]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(23) + } + [5]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(66) + } +} +bool(true) +array(8) { + [0]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(5) "Lemon" + } + [1]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(6) "Orange" + } + [2]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(5) "aPPle" + } + [3]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(5) "apple" + } + [4]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(3) "axx" + } + [5]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(2) "py" + } + [6]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(1) "t" + } + [7]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(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) { + [u"class_value"]=> + int(-5) + } + [1]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(0) + } + [2]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + float(0.001) + } + [3]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(11) + } + [4]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(23) + } + [5]=> + object(for_integer_sort)#%d (1) { + [u"class_value"]=> + int(66) + } +} +bool(true) +array(8) { + [0]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(5) "Lemon" + } + [1]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(6) "Orange" + } + [2]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(5) "aPPle" + } + [3]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(5) "apple" + } + [4]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(3) "axx" + } + [5]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(2) "py" + } + [6]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(1) "t" + } + [7]=> + object(for_string_sort)#%d (1) { + [u"class_value"]=> + unicode(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 0000000000..2db9e2e70c --- /dev/null +++ b/ext/standard/tests/array/sort_object2.phpt @@ -0,0 +1,423 @@ +--TEST-- +<<<<<<< .mine +Test sort() function : object functionality - sorting objects with diff. accessiblity of member vars +======= +Test sort() function : usage variations - sorting objects with diff. accessiblity of member vars +>>>>>>> .r17831 +--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 +--UEXPECTF-- +*** 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) { + [u"public_class_value"]=> + int(-88) + [u"private_class_value":u"for_integer_sort":private]=> + int(-5) + [u"protected_class_value":protected]=> + int(5) + } + [1]=> + object(for_integer_sort)#%d (3) { + [u"public_class_value"]=> + float(0.001) + [u"private_class_value":u"for_integer_sort":private]=> + float(99.5) + [u"protected_class_value":protected]=> + float(0.1) + } + [2]=> + object(for_integer_sort)#%d (3) { + [u"public_class_value"]=> + int(11) + [u"private_class_value":u"for_integer_sort":private]=> + int(33) + [u"protected_class_value":protected]=> + int(30) + } + [3]=> + object(for_integer_sort)#%d (3) { + [u"public_class_value"]=> + int(66) + [u"private_class_value":u"for_integer_sort":private]=> + int(44) + [u"protected_class_value":protected]=> + int(4) + } +} +bool(true) +array(4) { + [0]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(3) "axx" + [u"private_class_value":u"for_string_sort":private]=> + unicode(3) "AXX" + [u"protected_class_value":protected]=> + unicode(3) "ass" + } + [1]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(2) "py" + [u"private_class_value":u"for_string_sort":private]=> + unicode(2) "PY" + [u"protected_class_value":protected]=> + unicode(2) "pt" + } + [2]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "t" + [u"private_class_value":u"for_string_sort":private]=> + unicode(3) "eee" + [u"protected_class_value":protected]=> + unicode(3) "abb" + } + [3]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "w" + [u"private_class_value":u"for_string_sort":private]=> + unicode(1) "W" + [u"protected_class_value":protected]=> + unicode(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) { + [u"public_class_value"]=> + int(-88) + [u"private_class_value":u"for_integer_sort":private]=> + int(-5) + [u"protected_class_value":protected]=> + int(5) + } + [1]=> + object(for_integer_sort)#%d (3) { + [u"public_class_value"]=> + float(0.001) + [u"private_class_value":u"for_integer_sort":private]=> + float(99.5) + [u"protected_class_value":protected]=> + float(0.1) + } + [2]=> + object(for_integer_sort)#%d (3) { + [u"public_class_value"]=> + int(11) + [u"private_class_value":u"for_integer_sort":private]=> + int(33) + [u"protected_class_value":protected]=> + int(30) + } + [3]=> + object(for_integer_sort)#%d (3) { + [u"public_class_value"]=> + int(66) + [u"private_class_value":u"for_integer_sort":private]=> + int(44) + [u"protected_class_value":protected]=> + int(4) + } +} +bool(true) +array(4) { + [0]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(3) "axx" + [u"private_class_value":u"for_string_sort":private]=> + unicode(3) "AXX" + [u"protected_class_value":protected]=> + unicode(3) "ass" + } + [1]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(2) "py" + [u"private_class_value":u"for_string_sort":private]=> + unicode(2) "PY" + [u"protected_class_value":protected]=> + unicode(2) "pt" + } + [2]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "t" + [u"private_class_value":u"for_string_sort":private]=> + unicode(3) "eee" + [u"protected_class_value":protected]=> + unicode(3) "abb" + } + [3]=> + object(for_string_sort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "w" + [u"private_class_value":u"for_string_sort":private]=> + unicode(1) "W" + [u"protected_class_value":protected]=> + unicode(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 0000000000..669099372d --- /dev/null +++ b/ext/standard/tests/array/sort_variation1.phpt @@ -0,0 +1,704 @@ +--TEST-- +Test sort() function : usage variations - unexpected values for 'array' 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 +--UEXPECTF-- +*** 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, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode 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, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: sort() expects parameter 1 to be array, Unicode 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 0000000000..b9d07e92c7 --- /dev/null +++ b/ext/standard/tests/array/sort_variation10.phpt @@ -0,0 +1,184 @@ +--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 +--UEXPECTF-- +*** 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 0000000000..66f8f05cd3 Binary files /dev/null and b/ext/standard/tests/array/sort_variation11.phpt differ diff --git a/ext/standard/tests/array/sort_variation2.phpt b/ext/standard/tests/array/sort_variation2.phpt new file mode 100644 index 0000000000..0f8c3f96a7 --- /dev/null +++ b/ext/standard/tests/array/sort_variation2.phpt @@ -0,0 +1,532 @@ +--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 +--UEXPECTF-- +*** 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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, Unicode 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 0000000000..f8bbecffab --- /dev/null +++ b/ext/standard/tests/array/sort_variation3.phpt @@ -0,0 +1,593 @@ +--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 +--UEXPECTF-- +*** 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 0000000000..b0656363df --- /dev/null +++ b/ext/standard/tests/array/sort_variation4.phpt @@ -0,0 +1,115 @@ +--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 +--UEXPECTF-- +*** 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 0000000000..fa21cfb22c --- /dev/null +++ b/ext/standard/tests/array/sort_variation5.phpt @@ -0,0 +1,420 @@ +--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 +--UEXPECTF-- +*** 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]=> + unicode(1) " " + [3]=> + unicode(1) " +" + [4]=> + unicode(1) " " + [5]=> + unicode(1) " " + [6]=> + unicode(1) " +" + [7]=> + unicode(2) "\a" + [8]=> + unicode(3) "\cx" + [9]=> + unicode(4) "\ddd" + [10]=> + unicode(2) "\e" + [11]=> + unicode(4) "\xhh" +} +- Sort flag = SORT_REGULAR - +bool(true) +array(12) { + [0]=> + NULL + [1]=> + NULL + [2]=> + unicode(1) " " + [3]=> + unicode(1) " +" + [4]=> + unicode(1) " " + [5]=> + unicode(1) " " + [6]=> + unicode(1) " +" + [7]=> + unicode(2) "\a" + [8]=> + unicode(3) "\cx" + [9]=> + unicode(4) "\ddd" + [10]=> + unicode(2) "\e" + [11]=> + unicode(4) "\xhh" +} +- Sort flag = SORT_STRING - +bool(true) +array(12) { + [0]=> + NULL + [1]=> + NULL + [2]=> + unicode(1) " " + [3]=> + unicode(1) " +" + [4]=> + unicode(1) " " + [5]=> + unicode(1) " " + [6]=> + unicode(1) " +" + [7]=> + unicode(2) "\a" + [8]=> + unicode(3) "\cx" + [9]=> + unicode(4) "\ddd" + [10]=> + unicode(2) "\e" + [11]=> + unicode(4) "\xhh" +} + +-- Iteration 2 -- +- With Default sort flag - +bool(true) +array(12) { + [0]=> + unicode(6) "BANANA" + [1]=> + unicode(6) "Orange" + [2]=> + unicode(4) "TTTT" + [3]=> + unicode(4) "Test" + [4]=> + unicode(1) "X" + [5]=> + unicode(5) "apple" + [6]=> + unicode(6) "banana" + [7]=> + unicode(5) "lemoN" + [8]=> + unicode(6) "oraNGe" + [9]=> + unicode(3) "ttt" + [10]=> + unicode(2) "ww" + [11]=> + unicode(1) "x" +} +- Sort flag = SORT_REGULAR - +bool(true) +array(12) { + [0]=> + unicode(6) "BANANA" + [1]=> + unicode(6) "Orange" + [2]=> + unicode(4) "TTTT" + [3]=> + unicode(4) "Test" + [4]=> + unicode(1) "X" + [5]=> + unicode(5) "apple" + [6]=> + unicode(6) "banana" + [7]=> + unicode(5) "lemoN" + [8]=> + unicode(6) "oraNGe" + [9]=> + unicode(3) "ttt" + [10]=> + unicode(2) "ww" + [11]=> + unicode(1) "x" +} +- Sort flag = SORT_STRING - +bool(true) +array(12) { + [0]=> + unicode(6) "BANANA" + [1]=> + unicode(6) "Orange" + [2]=> + unicode(4) "TTTT" + [3]=> + unicode(4) "Test" + [4]=> + unicode(1) "X" + [5]=> + unicode(5) "apple" + [6]=> + unicode(6) "banana" + [7]=> + unicode(5) "lemoN" + [8]=> + unicode(6) "oraNGe" + [9]=> + unicode(3) "ttt" + [10]=> + unicode(2) "ww" + [11]=> + unicode(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 0000000000..e2bc86b7c8 --- /dev/null +++ b/ext/standard/tests/array/sort_variation6.phpt @@ -0,0 +1,208 @@ +--TEST-- +Test sort() function : usage variations - sort hexadecimals 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 +--UEXPECTF-- +*** 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 0000000000..5ed578e552 --- /dev/null +++ b/ext/standard/tests/array/sort_variation7.phpt @@ -0,0 +1,153 @@ +--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 +--UEXPECTF-- +*** 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 0000000000..3a4f4cf5cc --- /dev/null +++ b/ext/standard/tests/array/sort_variation8.phpt @@ -0,0 +1,299 @@ +--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 +--UEXPECTF-- +*** 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 0000000000..1fc1205446 --- /dev/null +++ b/ext/standard/tests/array/sort_variation9.phpt @@ -0,0 +1,464 @@ +--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 +--UEXPECTF-- +*** 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]=> + unicode(5) "first" + [5]=> + unicode(6) "second" + [6]=> + unicode(5) "third" + } + [1]=> + array(3) { + [u"a"]=> + unicode(6) "orange" + [u"b"]=> + unicode(6) "banana" + [u"c"]=> + unicode(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]=> + unicode(5) "first" + [5]=> + unicode(6) "second" + [6]=> + unicode(5) "third" + } + [1]=> + array(3) { + [u"a"]=> + unicode(6) "orange" + [u"b"]=> + unicode(6) "banana" + [u"c"]=> + unicode(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]=> + unicode(3) "baz" + [1]=> + int(1) +} +- Sort flag = SORT_REGULAR - +bool(true) +array(2) { + [0]=> + unicode(3) "baz" + [1]=> + int(1) +} + +-- Iteration 5 -- +- With Defualt sort flag - +bool(true) +array(4) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + array(1) { + [u"g"]=> + int(4) + } + [3]=> + array(2) { + [u"e"]=> + int(2) + [u"f"]=> + int(3) + } +} +- Sort flag = SORT_REGULAR - +bool(true) +array(4) { + [0]=> + int(1) + [1]=> + int(5) + [2]=> + array(1) { + [u"g"]=> + int(4) + } + [3]=> + array(2) { + [u"e"]=> + int(2) + [u"f"]=> + int(3) + } +} +Done