From: Raghubansh Kumar Date: Mon, 5 Nov 2007 16:34:54 +0000 (+0000) Subject: New testcases for asort() function X-Git-Tag: RELEASE_2_0_0a1~1457 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57076f08ddbb6698e3569022d47f7fc6f32309d9;p=php New testcases for asort() function --- diff --git a/ext/standard/tests/array/asort_basic.phpt b/ext/standard/tests/array/asort_basic.phpt new file mode 100644 index 0000000000..4bcbed38f4 --- /dev/null +++ b/ext/standard/tests/array/asort_basic.phpt @@ -0,0 +1,208 @@ +--TEST-- +Test asort() function : basic functionality +--FILE-- + "lemon", "o" => "orange", "b" => "banana" ); +// an array containing unsorted numeric values with indices +$unsorted_numerics = array( 1 => 100, 2 => 33, 3 => 555, 4 => 22 ); + +echo "\n-- Testing asort() by supplying string array, 'flag' value is default --\n"; +$temp_array = $unsorted_strings; +var_dump( asort($temp_array) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying numeric array, 'flag' value is default --\n"; +$temp_array = $unsorted_numerics; +var_dump( asort($temp_array) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying string array, 'flag' = SORT_REGULAR --\n"; +$temp_array = $unsorted_strings; +var_dump( asort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying numeric array, 'flag' = SORT_REGULAR --\n"; +$temp_array = $unsorted_numerics; +var_dump( asort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying string array, 'flag' = SORT_STRING --\n"; +$temp_array = $unsorted_strings; +var_dump( asort($temp_array, SORT_STRING) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying numeric array, 'flag' = SORT_NUMERIC --\n"; +$temp_array = $unsorted_numerics; +var_dump( asort($temp_array, SORT_NUMERIC) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : basic functionality *** + +-- Testing asort() by supplying string array, 'flag' value is default -- +bool(true) +array(3) { + ["b"]=> + string(6) "banana" + ["l"]=> + string(5) "lemon" + ["o"]=> + string(6) "orange" +} + +-- Testing asort() by supplying numeric array, 'flag' value is default -- +bool(true) +array(4) { + [4]=> + int(22) + [2]=> + int(33) + [1]=> + int(100) + [3]=> + int(555) +} + +-- Testing asort() by supplying string array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + ["b"]=> + string(6) "banana" + ["l"]=> + string(5) "lemon" + ["o"]=> + string(6) "orange" +} + +-- Testing asort() by supplying numeric array, 'flag' = SORT_REGULAR -- +bool(true) +array(4) { + [4]=> + int(22) + [2]=> + int(33) + [1]=> + int(100) + [3]=> + int(555) +} + +-- Testing asort() by supplying string array, 'flag' = SORT_STRING -- +bool(true) +array(3) { + ["b"]=> + string(6) "banana" + ["l"]=> + string(5) "lemon" + ["o"]=> + string(6) "orange" +} + +-- Testing asort() by supplying numeric array, 'flag' = SORT_NUMERIC -- +bool(true) +array(4) { + [4]=> + int(22) + [2]=> + int(33) + [1]=> + int(100) + [3]=> + int(555) +} +Done +--UEXPECTF-- +*** Testing asort() : basic functionality *** + +-- Testing asort() by supplying string array, 'flag' value is default -- +bool(true) +array(3) { + [u"b"]=> + unicode(6) "banana" + [u"l"]=> + unicode(5) "lemon" + [u"o"]=> + unicode(6) "orange" +} + +-- Testing asort() by supplying numeric array, 'flag' value is default -- +bool(true) +array(4) { + [4]=> + int(22) + [2]=> + int(33) + [1]=> + int(100) + [3]=> + int(555) +} + +-- Testing asort() by supplying string array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [u"b"]=> + unicode(6) "banana" + [u"l"]=> + unicode(5) "lemon" + [u"o"]=> + unicode(6) "orange" +} + +-- Testing asort() by supplying numeric array, 'flag' = SORT_REGULAR -- +bool(true) +array(4) { + [4]=> + int(22) + [2]=> + int(33) + [1]=> + int(100) + [3]=> + int(555) +} + +-- Testing asort() by supplying string array, 'flag' = SORT_STRING -- +bool(true) +array(3) { + [u"b"]=> + unicode(6) "banana" + [u"l"]=> + unicode(5) "lemon" + [u"o"]=> + unicode(6) "orange" +} + +-- Testing asort() by supplying numeric array, 'flag' = SORT_NUMERIC -- +bool(true) +array(4) { + [4]=> + int(22) + [2]=> + int(33) + [1]=> + int(100) + [3]=> + int(555) +} +Done diff --git a/ext/standard/tests/array/asort_error.phpt b/ext/standard/tests/array/asort_error.phpt new file mode 100644 index 0000000000..277411d9b2 --- /dev/null +++ b/ext/standard/tests/array/asort_error.phpt @@ -0,0 +1,122 @@ +--TEST-- +Test asort() 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($flags as $key => $flag){ + echo "\nSort flag = $key\n"; + var_dump( asort($array_arg,$flag, $extra_arg) ); + + // dump the input array to ensure that it wasn't changed + var_dump($array_arg); +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing asort() : error conditions *** + +-- Testing asort() function with Zero arguments -- + +Warning: asort() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing asort() function with more than expected no. of arguments -- + +Sort flag = SORT_REGULAR + +Warning: asort() 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: asort() 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: asort() 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 asort() : error conditions *** + +-- Testing asort() function with Zero arguments -- + +Warning: asort() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing asort() function with more than expected no. of arguments -- + +Sort flag = SORT_REGULAR + +Warning: asort() 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: asort() 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: asort() 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/asort_object1.phpt b/ext/standard/tests/array/asort_object1.phpt new file mode 100644 index 0000000000..88d6b141a1 --- /dev/null +++ b/ext/standard/tests/array/asort_object1.phpt @@ -0,0 +1,402 @@ +--TEST-- +Test asort() function : object functionality - sort objects +--FILE-- +class_value = $value; + } +} + +// class declaration for string objects +class for_string_asort +{ + 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 ( + 1 => new for_integer_asort(11), 2 => new for_integer_asort(66), + 3 => new for_integer_asort(23), 4 => new for_integer_asort(-5), + 5 => new for_integer_asort(0.001), 6 => new for_integer_asort(0) +); + +// array of string objects +$unsorted_str_obj = array ( + "a" => new for_string_asort("axx"), "b" => new for_string_asort("t"), + "c" => new for_string_asort("w"), "d" => new for_string_asort("py"), + "e" => new for_string_asort("apple"), "f" => new for_string_asort("Orange"), + "g" => new for_string_asort("Lemon"), "h" => new for_string_asort("aPPle") +); + + +echo "\n-- Testing asort() by supplying various object arrays, 'flag' value is default --\n"; + +// testing asort() function by supplying integer object array, flag value is default +$temp_array = $unsorted_int_obj; +var_dump(asort($temp_array) ); +var_dump($temp_array); + +// testing asort() function by supplying string object array, flag value is default +$temp_array = $unsorted_str_obj; +var_dump(asort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n"; +// testing asort() function by supplying integer object array, flag value = SORT_REGULAR +$temp_array = $unsorted_int_obj; +var_dump(asort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +// testing asort() function by supplying string object array, flag value = SORT_REGULAR +$temp_array = $unsorted_str_obj; +var_dump(asort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : object functionality *** + +-- Testing asort() by supplying various object arrays, 'flag' value is default -- +bool(true) +array(6) { + [4]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(-5) + } + [6]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(0) + } + [5]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + float(0.001) + } + [1]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(11) + } + [3]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(23) + } + [2]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(66) + } +} +bool(true) +array(8) { + ["g"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } + ["f"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + ["h"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + ["e"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + ["a"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + ["d"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + ["b"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + ["c"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(1) "w" + } +} + +-- Testing asort() by supplying various object arrays, 'flag' value is SORT_REGULAR -- +bool(true) +array(6) { + [4]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(-5) + } + [6]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(0) + } + [5]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + float(0.001) + } + [1]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(11) + } + [3]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(23) + } + [2]=> + object(for_integer_asort)#%d (1) { + ["class_value"]=> + int(66) + } +} +bool(true) +array(8) { + ["g"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } + ["f"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + ["h"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + ["e"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + ["a"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + ["d"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + ["b"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + ["c"]=> + object(for_string_asort)#%d (1) { + ["class_value"]=> + string(1) "w" + } +} +Done +--UEXPECTF-- +*** Testing asort() : object functionality *** + +-- Testing asort() by supplying various object arrays, 'flag' value is default -- +bool(true) +array(6) { + [4]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(-5) + } + [6]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(0) + } + [5]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + float(0.001) + } + [1]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(11) + } + [3]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(23) + } + [2]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(66) + } +} +bool(true) +array(8) { + [u"g"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(5) "Lemon" + } + [u"f"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(6) "Orange" + } + [u"h"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(5) "aPPle" + } + [u"e"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(5) "apple" + } + [u"a"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(3) "axx" + } + [u"d"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(2) "py" + } + [u"b"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(1) "t" + } + [u"c"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(1) "w" + } +} + +-- Testing asort() by supplying various object arrays, 'flag' value is SORT_REGULAR -- +bool(true) +array(6) { + [4]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(-5) + } + [6]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(0) + } + [5]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + float(0.001) + } + [1]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(11) + } + [3]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(23) + } + [2]=> + object(for_integer_asort)#%d (1) { + [u"class_value"]=> + int(66) + } +} +bool(true) +array(8) { + [u"g"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(5) "Lemon" + } + [u"f"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(6) "Orange" + } + [u"h"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(5) "aPPle" + } + [u"e"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(5) "apple" + } + [u"a"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(3) "axx" + } + [u"d"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(2) "py" + } + [u"b"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(1) "t" + } + [u"c"]=> + object(for_string_asort)#%d (1) { + [u"class_value"]=> + unicode(1) "w" + } +} +Done diff --git a/ext/standard/tests/array/asort_object2.phpt b/ext/standard/tests/array/asort_object2.phpt new file mode 100644 index 0000000000..ad442ec471 --- /dev/null +++ b/ext/standard/tests/array/asort_object2.phpt @@ -0,0 +1,416 @@ +--TEST-- +Test asort() function : object functionality - sorting objects with diff. accessibility 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_asort +{ + 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 ( + 1 => new for_integer_asort(11, 33,2), 2 => new for_integer_asort(44, 66,3), + 3 => new for_integer_asort(23, 32,6), 4 => new for_integer_asort(-88, -5,-4), +); + +// array of string objects +$unsorted_str_obj = array ( + "a" => new for_string_asort("axx","AXX","d"), "b" => new for_string_asort("T", "t","q"), + "c" => new for_string_asort("w", "W","c"), "d" => new for_string_asort("PY", "py","s"), +); + + +echo "\n-- Testing asort() by supplying various object arrays, 'flag' value is default --\n"; + +// testing asort() function by supplying integer object array, flag value is default +$temp_array = $unsorted_int_obj; +var_dump(asort($temp_array) ); +var_dump($temp_array); + +// testing asort() function by supplying string object array, flag value is default +$temp_array = $unsorted_str_obj; +var_dump(asort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n"; +// testing asort() function by supplying integer object array, flag value = SORT_REGULAR +$temp_array = $unsorted_int_obj; +var_dump(asort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +// testing asort() function by supplying string object array, flag value = SORT_REGULAR +$temp_array = $unsorted_str_obj; +var_dump(asort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : object functionality *** + +-- Testing asort() by supplying various object arrays, 'flag' value is default -- +bool(true) +array(4) { + [4]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(-88) + ["private_class_value":"for_integer_asort":private]=> + int(-5) + ["protected_class_value":protected]=> + int(-4) + } + [1]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(11) + ["private_class_value":"for_integer_asort":private]=> + int(33) + ["protected_class_value":protected]=> + int(2) + } + [3]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(23) + ["private_class_value":"for_integer_asort":private]=> + int(32) + ["protected_class_value":protected]=> + int(6) + } + [2]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(44) + ["private_class_value":"for_integer_asort":private]=> + int(66) + ["protected_class_value":protected]=> + int(3) + } +} +bool(true) +array(4) { + ["d"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(2) "PY" + ["private_class_value":"for_string_asort":private]=> + string(2) "py" + ["protected_class_value":protected]=> + string(1) "s" + } + ["b"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(1) "T" + ["private_class_value":"for_string_asort":private]=> + string(1) "t" + ["protected_class_value":protected]=> + string(1) "q" + } + ["a"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value":"for_string_asort":private]=> + string(3) "AXX" + ["protected_class_value":protected]=> + string(1) "d" + } + ["c"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value":"for_string_asort":private]=> + string(1) "W" + ["protected_class_value":protected]=> + string(1) "c" + } +} + +-- Testing asort() by supplying various object arrays, 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [4]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(-88) + ["private_class_value":"for_integer_asort":private]=> + int(-5) + ["protected_class_value":protected]=> + int(-4) + } + [1]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(11) + ["private_class_value":"for_integer_asort":private]=> + int(33) + ["protected_class_value":protected]=> + int(2) + } + [3]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(23) + ["private_class_value":"for_integer_asort":private]=> + int(32) + ["protected_class_value":protected]=> + int(6) + } + [2]=> + object(for_integer_asort)#%d (3) { + ["public_class_value"]=> + int(44) + ["private_class_value":"for_integer_asort":private]=> + int(66) + ["protected_class_value":protected]=> + int(3) + } +} +bool(true) +array(4) { + ["d"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(2) "PY" + ["private_class_value":"for_string_asort":private]=> + string(2) "py" + ["protected_class_value":protected]=> + string(1) "s" + } + ["b"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(1) "T" + ["private_class_value":"for_string_asort":private]=> + string(1) "t" + ["protected_class_value":protected]=> + string(1) "q" + } + ["a"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value":"for_string_asort":private]=> + string(3) "AXX" + ["protected_class_value":protected]=> + string(1) "d" + } + ["c"]=> + object(for_string_asort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value":"for_string_asort":private]=> + string(1) "W" + ["protected_class_value":protected]=> + string(1) "c" + } +} +Done +--UEXPECTF-- +*** Testing asort() : object functionality *** + +-- Testing asort() by supplying various object arrays, 'flag' value is default -- +bool(true) +array(4) { + [4]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(-88) + [u"private_class_value":u"for_integer_asort":private]=> + int(-5) + [u"protected_class_value":protected]=> + int(-4) + } + [1]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(11) + [u"private_class_value":u"for_integer_asort":private]=> + int(33) + [u"protected_class_value":protected]=> + int(2) + } + [3]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(23) + [u"private_class_value":u"for_integer_asort":private]=> + int(32) + [u"protected_class_value":protected]=> + int(6) + } + [2]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(44) + [u"private_class_value":u"for_integer_asort":private]=> + int(66) + [u"protected_class_value":protected]=> + int(3) + } +} +bool(true) +array(4) { + [u"d"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(2) "PY" + [u"private_class_value":u"for_string_asort":private]=> + unicode(2) "py" + [u"protected_class_value":protected]=> + unicode(1) "s" + } + [u"b"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "T" + [u"private_class_value":u"for_string_asort":private]=> + unicode(1) "t" + [u"protected_class_value":protected]=> + unicode(1) "q" + } + [u"a"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(3) "axx" + [u"private_class_value":u"for_string_asort":private]=> + unicode(3) "AXX" + [u"protected_class_value":protected]=> + unicode(1) "d" + } + [u"c"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "w" + [u"private_class_value":u"for_string_asort":private]=> + unicode(1) "W" + [u"protected_class_value":protected]=> + unicode(1) "c" + } +} + +-- Testing asort() by supplying various object arrays, 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [4]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(-88) + [u"private_class_value":u"for_integer_asort":private]=> + int(-5) + [u"protected_class_value":protected]=> + int(-4) + } + [1]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(11) + [u"private_class_value":u"for_integer_asort":private]=> + int(33) + [u"protected_class_value":protected]=> + int(2) + } + [3]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(23) + [u"private_class_value":u"for_integer_asort":private]=> + int(32) + [u"protected_class_value":protected]=> + int(6) + } + [2]=> + object(for_integer_asort)#%d (3) { + [u"public_class_value"]=> + int(44) + [u"private_class_value":u"for_integer_asort":private]=> + int(66) + [u"protected_class_value":protected]=> + int(3) + } +} +bool(true) +array(4) { + [u"d"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(2) "PY" + [u"private_class_value":u"for_string_asort":private]=> + unicode(2) "py" + [u"protected_class_value":protected]=> + unicode(1) "s" + } + [u"b"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "T" + [u"private_class_value":u"for_string_asort":private]=> + unicode(1) "t" + [u"protected_class_value":protected]=> + unicode(1) "q" + } + [u"a"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(3) "axx" + [u"private_class_value":u"for_string_asort":private]=> + unicode(3) "AXX" + [u"protected_class_value":protected]=> + unicode(1) "d" + } + [u"c"]=> + object(for_string_asort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "w" + [u"private_class_value":u"for_string_asort":private]=> + unicode(1) "W" + [u"protected_class_value":protected]=> + unicode(1) "c" + } +} +Done diff --git a/ext/standard/tests/array/asort_variation1.phpt b/ext/standard/tests/array/asort_variation1.phpt new file mode 100644 index 0000000000..0b14cfd3c1 --- /dev/null +++ b/ext/standard/tests/array/asort_variation1.phpt @@ -0,0 +1,705 @@ +--TEST-- +Test asort() function : usage variations - unexpected values for 'array_arg' argument +--FILE-- + 0, + 1 => 1, + 2 => 12345, + 3 => -2345, + + // float data + 4 => 10.5, + 5 => -10.5, + 6 => 10.5e3, + 7 => 10.6E-2, + 8 => .5, + + // null data + 9 => NULL, + 10 => null, + + // boolean data + 11 => true, + 12 => false, + 13 => TRUE, + 14 => FALSE, + + // empty data + 15 => "", + 16 => '', + + // string data + 17 => "string", + 18 => 'string', + + // object data + 19 => new stdclass(), + + // undefined data + 20 => @undefined_var, + + // unset data + 21 => @unset_var, + + // resource variable + 22 => $fp + +); + +// loop though each element of the array and check the working of asort() +// when $array arugment is supplied with different values from $unexpected_values +echo "\n-- Testing asort() by supplying different unexpected values for 'array' argument --\n"; +echo "\n-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --\n"; + +$counter = 1; +for($index = 0; $index < count($unexpected_values); $index ++) { + echo "-- Iteration $counter --\n"; + $value = $unexpected_values [$index]; + var_dump( asort($value) ); // expecting : bool(false) + var_dump( asort($value, SORT_REGULAR) ); // expecting : bool(false) + var_dump( asort($value, SORT_NUMERIC) ); // expecting : bool(false) + var_dump( asort($value, SORT_STRING) ); // expecting : bool(false) + $counter++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying different unexpected values for 'array' argument -- + +-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING -- +-- Iteration 1 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 11 -- + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 12 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 14 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +-- Iteration 21 -- + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, string given in %s on line %d +bool(false) +-- Iteration 23 -- + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying different unexpected values for 'array' argument -- + +-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING -- +-- Iteration 1 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, integer given in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, double given in %s on line %d +bool(false) +-- Iteration 10 -- + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 11 -- + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, null given in %s on line %d +bool(false) +-- Iteration 12 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 14 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 15 -- + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, boolean given in %s on line %d +bool(false) +-- Iteration 16 -- + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, object given in %s on line %d +bool(false) +-- Iteration 21 -- + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, Unicode string given in %s on line %d +bool(false) +-- Iteration 23 -- + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) + +Warning: asort() expects parameter 1 to be array, resource given in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/asort_variation10.phpt b/ext/standard/tests/array/asort_variation10.phpt new file mode 100644 index 0000000000..7fee59b901 --- /dev/null +++ b/ext/standard/tests/array/asort_variation10.phpt @@ -0,0 +1,187 @@ +--TEST-- +Test asort() function : usage variations - sort octal values +--FILE-- + 01235, 0321 => 0321, 0345 => 0345, 066 => 066, 0772 => 0772, + 077 => 077, -066 => -066, -0345 => -0345, 0 => 0 +); + +echo "\n-- Testing asort() by supplying octal value array, 'flag' value is default --\n"; +$temp_array = $unsorted_oct_array; +var_dump( asort($temp_array) ); // expecting : bool(true) +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying octal value array, 'flag' value is SORT_REGULAR --\n"; +$temp_array = $unsorted_oct_array; +var_dump( asort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying octal value array, 'flag' value is SORT_NUMERIC --\n"; +$temp_array = $unsorted_oct_array; +var_dump( asort($temp_array, SORT_NUMERIC) ); // expecting : bool(true) +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying octal value array, 'flag' value is default -- +bool(true) +array(9) { + [-229]=> + int(-229) + [-54]=> + int(-54) + [0]=> + int(0) + [54]=> + int(54) + [63]=> + int(63) + [209]=> + int(209) + [229]=> + int(229) + [506]=> + int(506) + [669]=> + int(669) +} + +-- Testing asort() by supplying octal value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(9) { + [-229]=> + int(-229) + [-54]=> + int(-54) + [0]=> + int(0) + [54]=> + int(54) + [63]=> + int(63) + [209]=> + int(209) + [229]=> + int(229) + [506]=> + int(506) + [669]=> + int(669) +} + +-- Testing asort() by supplying octal value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(9) { + [-229]=> + int(-229) + [-54]=> + int(-54) + [0]=> + int(0) + [54]=> + int(54) + [63]=> + int(63) + [209]=> + int(209) + [229]=> + int(229) + [506]=> + int(506) + [669]=> + int(669) +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying octal value array, 'flag' value is default -- +bool(true) +array(9) { + [-229]=> + int(-229) + [-54]=> + int(-54) + [0]=> + int(0) + [54]=> + int(54) + [63]=> + int(63) + [209]=> + int(209) + [229]=> + int(229) + [506]=> + int(506) + [669]=> + int(669) +} + +-- Testing asort() by supplying octal value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(9) { + [-229]=> + int(-229) + [-54]=> + int(-54) + [0]=> + int(0) + [54]=> + int(54) + [63]=> + int(63) + [209]=> + int(209) + [229]=> + int(229) + [506]=> + int(506) + [669]=> + int(669) +} + +-- Testing asort() by supplying octal value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(9) { + [-229]=> + int(-229) + [-54]=> + int(-54) + [0]=> + int(0) + [54]=> + int(54) + [63]=> + int(63) + [209]=> + int(209) + [229]=> + int(229) + [506]=> + int(506) + [669]=> + int(669) +} +Done diff --git a/ext/standard/tests/array/asort_variation11.phpt b/ext/standard/tests/array/asort_variation11.phpt new file mode 100644 index 0000000000..d35356bdd0 Binary files /dev/null and b/ext/standard/tests/array/asort_variation11.phpt differ diff --git a/ext/standard/tests/array/asort_variation2.phpt b/ext/standard/tests/array/asort_variation2.phpt new file mode 100644 index 0000000000..3c8667ea40 --- /dev/null +++ b/ext/standard/tests/array/asort_variation2.phpt @@ -0,0 +1,529 @@ +--TEST-- +Test asort() function : usage variations - unexpected values for 'sort_flags' argument +--FILE-- + 10, 2 => 2, 3 => 45); + +//array of values to iterate over +$unexpected_values = array( + + // int data +/*1*/ -2345, + + // float data +/*2*/ 10.5, + -10.5, + 10.5e2, + 10.6E-2, + .5, + + // null data +/*7*/ NULL, + null, + + // boolean data +/*9*/ true, + false, + TRUE, + FALSE, + + // empty data +/*13*/ "", + '', + + // string data +/*15*/ "string", + 'string', + + // object data +/*16*/ new stdclass(), + + // undefined data +/*17*/ @undefined_var, + + // unset data +/*18*/ @unset_var, + + // resource variable +/*19*/ $fp + +); + +// loop though each element of the array and check the working of asort() +// when $flag arugment is supplied with different values from $unexpected_values +echo "\n-- Testing asort() by supplying different unexpected values for 'sort_flags' argument --\n"; + +$counter = 1; +for($index = 0; $index < count($unexpected_values); $index ++) { + echo "-- Iteration $counter --\n"; + $value = $unexpected_values [$index]; + $temp_array = $unsorted_values; + var_dump( asort($temp_array, $value) ); + var_dump($temp_array); + $counter++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying different unexpected values for 'sort_flags' argument -- +-- Iteration 1 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 2 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 3 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 4 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 5 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 6 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 7 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 8 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 9 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 10 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 11 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 12 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 13 -- + +Warning: asort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 14 -- + +Warning: asort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 15 -- + +Warning: asort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 16 -- + +Warning: asort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 17 -- + +Warning: asort() expects parameter 2 to be long, object given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 18 -- + +Warning: asort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 19 -- + +Warning: asort() expects parameter 2 to be long, string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 20 -- + +Warning: asort() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying different unexpected values for 'sort_flags' argument -- +-- Iteration 1 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 2 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 3 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 4 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 5 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 6 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 7 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 8 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 9 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 10 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 11 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 12 -- +bool(true) +array(3) { + [2]=> + int(2) + [1]=> + int(10) + [3]=> + int(45) +} +-- Iteration 13 -- + +Warning: asort() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 14 -- + +Warning: asort() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 15 -- + +Warning: asort() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 16 -- + +Warning: asort() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 17 -- + +Warning: asort() expects parameter 2 to be long, object given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 18 -- + +Warning: asort() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 19 -- + +Warning: asort() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +-- Iteration 20 -- + +Warning: asort() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +array(3) { + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(45) +} +Done diff --git a/ext/standard/tests/array/asort_variation3.phpt b/ext/standard/tests/array/asort_variation3.phpt new file mode 100644 index 0000000000..7b8b8bcb8f --- /dev/null +++ b/ext/standard/tests/array/asort_variation3.phpt @@ -0,0 +1,591 @@ +--TEST-- +Test asort() function : usage variations - sort integer/float values +--FILE-- + 11, 2 => -11, 3 => 21, 4 => -21, 5 => 31, 6 => -31, 7 => 0, 8 => 41, 10 =>-41), + + // float value array + array(1 => 10.5, 2 => -10.5, 3 => 10.5e2, 4 => 10.6E-2, 5 => .5, 6 => .0001, 7 => -.1), + + // mixed value array + array(1 => .0001, 2 => .0021, 3 => -.01, 4 => -1, 5 => 0, 6 => .09, 7 => 2, 8 => -.9, 9 => 10.6E-2, 10 => -10.6E-2, 11 => 33), + + // array values contains minimum and maximum ranges + array(1 => 2147483647, 2 => 2147483648, 3 => -2147483647, 4 => -2147483648, 5 => -0, 6 => 0, 7 => -2147483649) +); + +// set of possible flag values +$flag_value = array("SORT_REGULAR" => SORT_REGULAR, "SORT_NUMERIC" => SORT_NUMERIC); + +$count = 1; +echo "\n-- Testing asort() by supplying various integer/float arrays --\n"; + +// loop through to test asort() with different arrays +foreach ($various_arrays as $array) { + echo "\n-- Iteration $count --\n"; + + echo "- With default sort_flag -\n"; + $temp_array = $array; + var_dump(asort($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(asort($temp_array, $flag) ); + var_dump($temp_array); + } + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various integer/float arrays -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(9) { + [10]=> + int(-41) + [6]=> + int(-31) + [4]=> + int(-21) + [2]=> + int(-11) + [7]=> + int(0) + [1]=> + int(11) + [3]=> + int(21) + [5]=> + int(31) + [8]=> + int(41) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(9) { + [10]=> + int(-41) + [6]=> + int(-31) + [4]=> + int(-21) + [2]=> + int(-11) + [7]=> + int(0) + [1]=> + int(11) + [3]=> + int(21) + [5]=> + int(31) + [8]=> + int(41) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(9) { + [10]=> + int(-41) + [6]=> + int(-31) + [4]=> + int(-21) + [2]=> + int(-11) + [7]=> + int(0) + [1]=> + int(11) + [3]=> + int(21) + [5]=> + int(31) + [8]=> + int(41) +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(7) { + [2]=> + float(-10.5) + [7]=> + float(-0.1) + [6]=> + float(0.0001) + [4]=> + float(0.106) + [5]=> + float(0.5) + [1]=> + float(10.5) + [3]=> + float(1050) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(7) { + [2]=> + float(-10.5) + [7]=> + float(-0.1) + [6]=> + float(0.0001) + [4]=> + float(0.106) + [5]=> + float(0.5) + [1]=> + float(10.5) + [3]=> + float(1050) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(7) { + [2]=> + float(-10.5) + [7]=> + float(-0.1) + [6]=> + float(0.0001) + [4]=> + float(0.106) + [5]=> + float(0.5) + [1]=> + float(10.5) + [3]=> + float(1050) +} + +-- Iteration 3 -- +- With default sort_flag - +bool(true) +array(11) { + [4]=> + int(-1) + [8]=> + float(-0.9) + [10]=> + float(-0.106) + [3]=> + float(-0.01) + [5]=> + int(0) + [1]=> + float(0.0001) + [2]=> + float(0.0021) + [6]=> + float(0.09) + [9]=> + float(0.106) + [7]=> + int(2) + [11]=> + int(33) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(11) { + [4]=> + int(-1) + [8]=> + float(-0.9) + [10]=> + float(-0.106) + [3]=> + float(-0.01) + [5]=> + int(0) + [1]=> + float(0.0001) + [2]=> + float(0.0021) + [6]=> + float(0.09) + [9]=> + float(0.106) + [7]=> + int(2) + [11]=> + int(33) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(11) { + [4]=> + int(-1) + [8]=> + float(-0.9) + [10]=> + float(-0.106) + [3]=> + float(-0.01) + [5]=> + int(0) + [1]=> + float(0.0001) + [2]=> + float(0.0021) + [6]=> + float(0.09) + [9]=> + float(0.106) + [7]=> + int(2) + [11]=> + int(33) +} + +-- Iteration 4 -- +- With default sort_flag - +bool(true) +array(7) { + [7]=> + float(-2147483649) + [4]=> + float(-2147483648) + [3]=> + int(-2147483647) + [6]=> + int(0) + [5]=> + int(0) + [1]=> + int(2147483647) + [2]=> + float(2147483648) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(7) { + [7]=> + float(-2147483649) + [4]=> + float(-2147483648) + [3]=> + int(-2147483647) + [6]=> + int(0) + [5]=> + int(0) + [1]=> + int(2147483647) + [2]=> + float(2147483648) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(7) { + [7]=> + float(-2147483649) + [4]=> + float(-2147483648) + [3]=> + int(-2147483647) + [6]=> + int(0) + [5]=> + int(0) + [1]=> + int(2147483647) + [2]=> + float(2147483648) +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various integer/float arrays -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(9) { + [10]=> + int(-41) + [6]=> + int(-31) + [4]=> + int(-21) + [2]=> + int(-11) + [7]=> + int(0) + [1]=> + int(11) + [3]=> + int(21) + [5]=> + int(31) + [8]=> + int(41) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(9) { + [10]=> + int(-41) + [6]=> + int(-31) + [4]=> + int(-21) + [2]=> + int(-11) + [7]=> + int(0) + [1]=> + int(11) + [3]=> + int(21) + [5]=> + int(31) + [8]=> + int(41) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(9) { + [10]=> + int(-41) + [6]=> + int(-31) + [4]=> + int(-21) + [2]=> + int(-11) + [7]=> + int(0) + [1]=> + int(11) + [3]=> + int(21) + [5]=> + int(31) + [8]=> + int(41) +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(7) { + [2]=> + float(-10.5) + [7]=> + float(-0.1) + [6]=> + float(0.0001) + [4]=> + float(0.106) + [5]=> + float(0.5) + [1]=> + float(10.5) + [3]=> + float(1050) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(7) { + [2]=> + float(-10.5) + [7]=> + float(-0.1) + [6]=> + float(0.0001) + [4]=> + float(0.106) + [5]=> + float(0.5) + [1]=> + float(10.5) + [3]=> + float(1050) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(7) { + [2]=> + float(-10.5) + [7]=> + float(-0.1) + [6]=> + float(0.0001) + [4]=> + float(0.106) + [5]=> + float(0.5) + [1]=> + float(10.5) + [3]=> + float(1050) +} + +-- Iteration 3 -- +- With default sort_flag - +bool(true) +array(11) { + [4]=> + int(-1) + [8]=> + float(-0.9) + [10]=> + float(-0.106) + [3]=> + float(-0.01) + [5]=> + int(0) + [1]=> + float(0.0001) + [2]=> + float(0.0021) + [6]=> + float(0.09) + [9]=> + float(0.106) + [7]=> + int(2) + [11]=> + int(33) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(11) { + [4]=> + int(-1) + [8]=> + float(-0.9) + [10]=> + float(-0.106) + [3]=> + float(-0.01) + [5]=> + int(0) + [1]=> + float(0.0001) + [2]=> + float(0.0021) + [6]=> + float(0.09) + [9]=> + float(0.106) + [7]=> + int(2) + [11]=> + int(33) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(11) { + [4]=> + int(-1) + [8]=> + float(-0.9) + [10]=> + float(-0.106) + [3]=> + float(-0.01) + [5]=> + int(0) + [1]=> + float(0.0001) + [2]=> + float(0.0021) + [6]=> + float(0.09) + [9]=> + float(0.106) + [7]=> + int(2) + [11]=> + int(33) +} + +-- Iteration 4 -- +- With default sort_flag - +bool(true) +array(7) { + [7]=> + float(-2147483649) + [4]=> + float(-2147483648) + [3]=> + int(-2147483647) + [6]=> + int(0) + [5]=> + int(0) + [1]=> + int(2147483647) + [2]=> + float(2147483648) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(7) { + [7]=> + float(-2147483649) + [4]=> + float(-2147483648) + [3]=> + int(-2147483647) + [6]=> + int(0) + [5]=> + int(0) + [1]=> + int(2147483647) + [2]=> + float(2147483648) +} +- Sort_flag = SORT_NUMERIC - +bool(true) +array(7) { + [7]=> + float(-2147483649) + [4]=> + float(-2147483648) + [3]=> + int(-2147483647) + [6]=> + int(0) + [5]=> + int(0) + [1]=> + int(2147483647) + [2]=> + float(2147483648) +} +Done diff --git a/ext/standard/tests/array/asort_variation4.phpt b/ext/standard/tests/array/asort_variation4.phpt new file mode 100644 index 0000000000..9e5f8666da --- /dev/null +++ b/ext/standard/tests/array/asort_variation4.phpt @@ -0,0 +1,115 @@ +--TEST-- +Test asort() function : usage variations - sort reference variables +--FILE-- + &$value1 , 2 => &$value2, 3 => &$value3); + +echo "\n-- Testing asort() by supplying reference variable array, 'flag' value is default --\n"; +$temp_array = $unsorted_numerics; +var_dump( asort($temp_array) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying reference variable array, 'flag' = SORT_REGULAR --\n"; +$temp_array = &$unsorted_numerics; +var_dump( asort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "\n-- Testing asort() by supplying reference variable array, 'flag' = SORT_NUMERIC --\n"; +$temp_array = &$unsorted_numerics; +var_dump( asort($temp_array, SORT_NUMERIC) ); // expecting : bool(true) +var_dump( $temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() :usage variations *** + +-- Testing asort() by supplying reference variable array, 'flag' value is default -- +bool(true) +array(3) { + [2]=> + &int(33) + [1]=> + &int(100) + [3]=> + &int(555) +} + +-- Testing asort() by supplying reference variable array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [2]=> + &int(33) + [1]=> + &int(100) + [3]=> + &int(555) +} + +-- Testing asort() by supplying reference variable array, 'flag' = SORT_NUMERIC -- +bool(true) +array(3) { + [2]=> + &int(33) + [1]=> + &int(100) + [3]=> + &int(555) +} +Done +--UEXPECTF-- +*** Testing asort() :usage variations *** + +-- Testing asort() by supplying reference variable array, 'flag' value is default -- +bool(true) +array(3) { + [2]=> + &int(33) + [1]=> + &int(100) + [3]=> + &int(555) +} + +-- Testing asort() by supplying reference variable array, 'flag' = SORT_REGULAR -- +bool(true) +array(3) { + [2]=> + &int(33) + [1]=> + &int(100) + [3]=> + &int(555) +} + +-- Testing asort() by supplying reference variable array, 'flag' = SORT_NUMERIC -- +bool(true) +array(3) { + [2]=> + &int(33) + [1]=> + &int(100) + [3]=> + &int(555) +} +Done diff --git a/ext/standard/tests/array/asort_variation5.phpt b/ext/standard/tests/array/asort_variation5.phpt new file mode 100644 index 0000000000..bb3cfe69e5 --- /dev/null +++ b/ext/standard/tests/array/asort_variation5.phpt @@ -0,0 +1,437 @@ +--TEST-- +Test asort() function : usage variations - sort strings +--FILE-- + null, "NULL" => NULL, "\a" => "\a", "\cx" => "\cx", "\e" => "\e", + "\f" => "\f", "\n" =>"\n", "\r" => "\r", "\t" => "\t", "\xhh" => "\xhh", + "\ddd" => "\ddd", "\v" => "\v" + ), + + // array contains combination of capital/small letters + array ('l' => "lemoN", 'O' => "Orange", 'b' => "banana", 'a' => "apple", 'Te' => "Test", + 'T' => "TTTT", 't' => "ttt", 'w' => "ww", 'x' => "x", 'X' => "X", 'o' => "oraNGe", + 'B' => "BANANA" + ) +); + +$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING); + +$count = 1; +echo "\n-- Testing asort() by supplying various string arrays --\n"; + +// loop through to test asort() with different arrays +foreach ($various_arrays as $array) { + echo "\n-- Iteration $count --\n"; + + echo "- With default sort_flag -\n"; + $temp_array = $array; + var_dump(asort($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(asort($temp_array, $flag) ); // expecting : bool(true) + var_dump($temp_array); + } + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various string arrays -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(12) { + ["null"]=> + NULL + ["NULL"]=> + NULL + [" "]=> + string(1) " " + [" +"]=> + string(1) " +" + [" "]=> + string(1) " " + [" "]=> + string(1) " " + [" +"]=> + string(1) " +" + ["\a"]=> + string(2) "\a" + ["\cx"]=> + string(3) "\cx" + ["\ddd"]=> + string(4) "\ddd" + ["\e"]=> + string(2) "\e" + ["\xhh"]=> + string(4) "\xhh" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(12) { + ["null"]=> + NULL + ["NULL"]=> + NULL + [" "]=> + string(1) " " + [" +"]=> + string(1) " +" + [" "]=> + string(1) " " + [" "]=> + string(1) " " + [" +"]=> + string(1) " +" + ["\a"]=> + string(2) "\a" + ["\cx"]=> + string(3) "\cx" + ["\ddd"]=> + string(4) "\ddd" + ["\e"]=> + string(2) "\e" + ["\xhh"]=> + string(4) "\xhh" +} +- Sort_flag = SORT_STRING - +bool(true) +array(12) { + ["null"]=> + NULL + ["NULL"]=> + NULL + [" "]=> + string(1) " " + [" +"]=> + string(1) " +" + [" "]=> + string(1) " " + [" "]=> + string(1) " " + [" +"]=> + string(1) " +" + ["\a"]=> + string(2) "\a" + ["\cx"]=> + string(3) "\cx" + ["\ddd"]=> + string(4) "\ddd" + ["\e"]=> + string(2) "\e" + ["\xhh"]=> + string(4) "\xhh" +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(12) { + ["B"]=> + string(6) "BANANA" + ["O"]=> + string(6) "Orange" + ["T"]=> + string(4) "TTTT" + ["Te"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["a"]=> + string(5) "apple" + ["b"]=> + string(6) "banana" + ["l"]=> + string(5) "lemoN" + ["o"]=> + string(6) "oraNGe" + ["t"]=> + string(3) "ttt" + ["w"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(12) { + ["B"]=> + string(6) "BANANA" + ["O"]=> + string(6) "Orange" + ["T"]=> + string(4) "TTTT" + ["Te"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["a"]=> + string(5) "apple" + ["b"]=> + string(6) "banana" + ["l"]=> + string(5) "lemoN" + ["o"]=> + string(6) "oraNGe" + ["t"]=> + string(3) "ttt" + ["w"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +- Sort_flag = SORT_STRING - +bool(true) +array(12) { + ["B"]=> + string(6) "BANANA" + ["O"]=> + string(6) "Orange" + ["T"]=> + string(4) "TTTT" + ["Te"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["a"]=> + string(5) "apple" + ["b"]=> + string(6) "banana" + ["l"]=> + string(5) "lemoN" + ["o"]=> + string(6) "oraNGe" + ["t"]=> + string(3) "ttt" + ["w"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various string arrays -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(12) { + [u"null"]=> + NULL + [u"NULL"]=> + NULL + [u" "]=> + unicode(1) " " + [u" +"]=> + unicode(1) " +" + [u" "]=> + unicode(1) " " + [u" "]=> + unicode(1) " " + [u" +"]=> + unicode(1) " +" + [u"\a"]=> + unicode(2) "\a" + [u"\cx"]=> + unicode(3) "\cx" + [u"\ddd"]=> + unicode(4) "\ddd" + [u"\e"]=> + unicode(2) "\e" + [u"\xhh"]=> + unicode(4) "\xhh" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(12) { + [u"null"]=> + NULL + [u"NULL"]=> + NULL + [u" "]=> + unicode(1) " " + [u" +"]=> + unicode(1) " +" + [u" "]=> + unicode(1) " " + [u" "]=> + unicode(1) " " + [u" +"]=> + unicode(1) " +" + [u"\a"]=> + unicode(2) "\a" + [u"\cx"]=> + unicode(3) "\cx" + [u"\ddd"]=> + unicode(4) "\ddd" + [u"\e"]=> + unicode(2) "\e" + [u"\xhh"]=> + unicode(4) "\xhh" +} +- Sort_flag = SORT_STRING - +bool(true) +array(12) { + [u"null"]=> + NULL + [u"NULL"]=> + NULL + [u" "]=> + unicode(1) " " + [u" +"]=> + unicode(1) " +" + [u" "]=> + unicode(1) " " + [u" "]=> + unicode(1) " " + [u" +"]=> + unicode(1) " +" + [u"\a"]=> + unicode(2) "\a" + [u"\cx"]=> + unicode(3) "\cx" + [u"\ddd"]=> + unicode(4) "\ddd" + [u"\e"]=> + unicode(2) "\e" + [u"\xhh"]=> + unicode(4) "\xhh" +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(12) { + [u"B"]=> + unicode(6) "BANANA" + [u"O"]=> + unicode(6) "Orange" + [u"T"]=> + unicode(4) "TTTT" + [u"Te"]=> + unicode(4) "Test" + [u"X"]=> + unicode(1) "X" + [u"a"]=> + unicode(5) "apple" + [u"b"]=> + unicode(6) "banana" + [u"l"]=> + unicode(5) "lemoN" + [u"o"]=> + unicode(6) "oraNGe" + [u"t"]=> + unicode(3) "ttt" + [u"w"]=> + unicode(2) "ww" + [u"x"]=> + unicode(1) "x" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(12) { + [u"B"]=> + unicode(6) "BANANA" + [u"O"]=> + unicode(6) "Orange" + [u"T"]=> + unicode(4) "TTTT" + [u"Te"]=> + unicode(4) "Test" + [u"X"]=> + unicode(1) "X" + [u"a"]=> + unicode(5) "apple" + [u"b"]=> + unicode(6) "banana" + [u"l"]=> + unicode(5) "lemoN" + [u"o"]=> + unicode(6) "oraNGe" + [u"t"]=> + unicode(3) "ttt" + [u"w"]=> + unicode(2) "ww" + [u"x"]=> + unicode(1) "x" +} +- Sort_flag = SORT_STRING - +bool(true) +array(12) { + [u"B"]=> + unicode(6) "BANANA" + [u"O"]=> + unicode(6) "Orange" + [u"T"]=> + unicode(4) "TTTT" + [u"Te"]=> + unicode(4) "Test" + [u"X"]=> + unicode(1) "X" + [u"a"]=> + unicode(5) "apple" + [u"b"]=> + unicode(6) "banana" + [u"l"]=> + unicode(5) "lemoN" + [u"o"]=> + unicode(6) "oraNGe" + [u"t"]=> + unicode(3) "ttt" + [u"w"]=> + unicode(2) "ww" + [u"x"]=> + unicode(1) "x" +} +Done diff --git a/ext/standard/tests/array/asort_variation6.phpt b/ext/standard/tests/array/asort_variation6.phpt new file mode 100644 index 0000000000..6620c0e719 --- /dev/null +++ b/ext/standard/tests/array/asort_variation6.phpt @@ -0,0 +1,186 @@ +--TEST-- +Test asort() function : usage variations - sort hexadecimal values +--FILE-- + 0x1AB, 0xFFF => 0xFFF, 0xF => 0xF, 0xFF => 0xFF, 0x2AA => 0x2AA, 0xBB => 0xBB, + 0x1ab => 0x1ab, 0xff => 0xff, -0xff => -0xFF, 0 => 0, -0x2aa => -0x2aa + ); + +echo "\n-- Testing asort() by supplying hexadecimal value array, 'flag' value is default --\n"; +$temp_array = $unsorted_hex_array; +var_dump(asort($temp_array) ); // expecting : bool(true) +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR --\n"; +$temp_array = $unsorted_hex_array; +var_dump(asort($temp_array, SORT_REGULAR) ); // expecting : bool(true) +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC --\n"; +$temp_array = $unsorted_hex_array; +var_dump(asort($temp_array, SORT_NUMERIC) ); // expecting : bool(true) +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying hexadecimal value array, 'flag' value is default -- +bool(true) +array(9) { + [-682]=> + int(-682) + [-255]=> + int(-255) + [0]=> + int(0) + [15]=> + int(15) + [187]=> + int(187) + [255]=> + int(255) + [427]=> + int(427) + [682]=> + int(682) + [4095]=> + int(4095) +} + +-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(9) { + [-682]=> + int(-682) + [-255]=> + int(-255) + [0]=> + int(0) + [15]=> + int(15) + [187]=> + int(187) + [255]=> + int(255) + [427]=> + int(427) + [682]=> + int(682) + [4095]=> + int(4095) +} + +-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(9) { + [-682]=> + int(-682) + [-255]=> + int(-255) + [0]=> + int(0) + [15]=> + int(15) + [187]=> + int(187) + [255]=> + int(255) + [427]=> + int(427) + [682]=> + int(682) + [4095]=> + int(4095) +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying hexadecimal value array, 'flag' value is default -- +bool(true) +array(9) { + [-682]=> + int(-682) + [-255]=> + int(-255) + [0]=> + int(0) + [15]=> + int(15) + [187]=> + int(187) + [255]=> + int(255) + [427]=> + int(427) + [682]=> + int(682) + [4095]=> + int(4095) +} + +-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(9) { + [-682]=> + int(-682) + [-255]=> + int(-255) + [0]=> + int(0) + [15]=> + int(15) + [187]=> + int(187) + [255]=> + int(255) + [427]=> + int(427) + [682]=> + int(682) + [4095]=> + int(4095) +} + +-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(9) { + [-682]=> + int(-682) + [-255]=> + int(-255) + [0]=> + int(0) + [15]=> + int(15) + [187]=> + int(187) + [255]=> + int(255) + [427]=> + int(427) + [682]=> + int(682) + [4095]=> + int(4095) +} +Done diff --git a/ext/standard/tests/array/asort_variation7.phpt b/ext/standard/tests/array/asort_variation7.phpt new file mode 100644 index 0000000000..2c8f1c3494 --- /dev/null +++ b/ext/standard/tests/array/asort_variation7.phpt @@ -0,0 +1,154 @@ +--TEST-- +Test asort() function : usage variations - sort bool values +--INI-- +--FILE-- + true, 2 => false, 3 => TRUE, 4 => FALSE); + +echo "\n-- Testing asort() by supplying bool value array, 'flag' value is default --\n"; +$temp_array = $bool_values; +var_dump(asort($temp_array) ); +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying bool value array, 'flag' value is SORT_REGULAR --\n"; +$temp_array = $bool_values; +var_dump(asort($temp_array, SORT_REGULAR) ); +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying bool value array, 'flag' value is SORT_NUMERIC --\n"; +$temp_array = $bool_values; +var_dump(asort($temp_array, SORT_NUMERIC) ); +var_dump($temp_array); + +echo "\n-- Testing asort() by supplying bool value array, 'flag' value is SORT_STRING --\n"; +$temp_array = $bool_values; +var_dump(asort($temp_array, SORT_STRING) ); +var_dump($temp_array); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying bool value array, 'flag' value is default -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing asort() by supplying bool value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing asort() by supplying bool value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing asort() by supplying bool value array, 'flag' value is SORT_STRING -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying bool value array, 'flag' value is default -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing asort() by supplying bool value array, 'flag' value is SORT_REGULAR -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing asort() by supplying bool value array, 'flag' value is SORT_NUMERIC -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} + +-- Testing asort() by supplying bool value array, 'flag' value is SORT_STRING -- +bool(true) +array(4) { + [4]=> + bool(false) + [2]=> + bool(false) + [1]=> + bool(true) + [3]=> + bool(true) +} +Done diff --git a/ext/standard/tests/array/asort_variation8.phpt b/ext/standard/tests/array/asort_variation8.phpt new file mode 100644 index 0000000000..2f9da35e0a --- /dev/null +++ b/ext/standard/tests/array/asort_variation8.phpt @@ -0,0 +1,301 @@ +--TEST-- +Test asort() function : usage variations - sort array with diff. sub arrays, 'sort_flag' as default/SORT_REGULAR +--FILE-- + array(), + + // array contains null sub array + "array[1]" => array( "sub_array[1][0]" => array() ), + + // array of arrays along with some values + "array[2]" => array("data[2,0]" => 44, "data[2,1]" => 11, "sub_array[2][0] " => array(64,61) ), + + // array contains sub arrays + "array[3]" => array ( "sub_array[3][0]" => array(33,-5,6), "sub_array[3][1]" => array(11), + "sub_array[3][2]" => array(22,-55), "sub_array[3][3]" => array() ) +); + + +$count = 1; +echo "\n-- Testing asort() by supplying various arrays containing sub arrays --\n"; + +// loop through to test asort() with different arrays +foreach ($various_arrays as $array) { + + echo "\n-- Iteration $count --\n"; + // testing asort() function by supplying different arrays, flag value is default + echo "- With default sort_flag -\n"; + $temp_array = $array; + var_dump(asort($temp_array) ); + var_dump($temp_array); + + // testing asort() function by supplying different arrays, flag value = SORT_REGULAR + echo "- Sort_flag = SORT_REGULAR -\n"; + $temp_array = $array; + var_dump(asort($temp_array, SORT_REGULAR) ); + var_dump($temp_array); + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various arrays containing sub arrays -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(0) { +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(0) { +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(1) { + ["sub_array[1][0]"]=> + array(0) { + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(1) { + ["sub_array[1][0]"]=> + array(0) { + } +} + +-- Iteration 3 -- +- With default sort_flag - +bool(true) +array(3) { + ["data[2,1]"]=> + int(11) + ["data[2,0]"]=> + int(44) + ["sub_array[2][0] "]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(3) { + ["data[2,1]"]=> + int(11) + ["data[2,0]"]=> + int(44) + ["sub_array[2][0] "]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } +} + +-- Iteration 4 -- +- With default sort_flag - +bool(true) +array(4) { + ["sub_array[3][3]"]=> + array(0) { + } + ["sub_array[3][1]"]=> + array(1) { + [0]=> + int(11) + } + ["sub_array[3][2]"]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + ["sub_array[3][0]"]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(4) { + ["sub_array[3][3]"]=> + array(0) { + } + ["sub_array[3][1]"]=> + array(1) { + [0]=> + int(11) + } + ["sub_array[3][2]"]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + ["sub_array[3][0]"]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various arrays containing sub arrays -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(0) { +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(0) { +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(1) { + [u"sub_array[1][0]"]=> + array(0) { + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(1) { + [u"sub_array[1][0]"]=> + array(0) { + } +} + +-- Iteration 3 -- +- With default sort_flag - +bool(true) +array(3) { + [u"data[2,1]"]=> + int(11) + [u"data[2,0]"]=> + int(44) + [u"sub_array[2][0] "]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(3) { + [u"data[2,1]"]=> + int(11) + [u"data[2,0]"]=> + int(44) + [u"sub_array[2][0] "]=> + array(2) { + [0]=> + int(64) + [1]=> + int(61) + } +} + +-- Iteration 4 -- +- With default sort_flag - +bool(true) +array(4) { + [u"sub_array[3][3]"]=> + array(0) { + } + [u"sub_array[3][1]"]=> + array(1) { + [0]=> + int(11) + } + [u"sub_array[3][2]"]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [u"sub_array[3][0]"]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(4) { + [u"sub_array[3][3]"]=> + array(0) { + } + [u"sub_array[3][1]"]=> + array(1) { + [0]=> + int(11) + } + [u"sub_array[3][2]"]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [u"sub_array[3][0]"]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } +} +Done diff --git a/ext/standard/tests/array/asort_variation9.phpt b/ext/standard/tests/array/asort_variation9.phpt new file mode 100644 index 0000000000..7de49e3307 --- /dev/null +++ b/ext/standard/tests/array/asort_variation9.phpt @@ -0,0 +1,465 @@ +--TEST-- +Test asort() function : usage variations - sorting array with/without keys, 'sort_flags' as default/SORT_REGULAR +--FILE-- + 55, 66, 22, 33, 11), + array ("a" => "orange", "banana", "c" => "apple"), + array(1, 2, 3, 4, 5, 6), + 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 asort() by supplying various arrays with key values --\n"; + +// loop through to test asort() 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 default sort_flag -\n"; + $temp_array = $array; + var_dump(asort($temp_array) ); + var_dump($temp_array); + + echo "- Sort_flag = SORT_REGULAR -\n"; + $temp_array = $array; + var_dump(asort($temp_array, SORT_REGULAR) ); + var_dump($temp_array); + $count++; +} + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various arrays with key values -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(5) { + [9]=> + int(11) + [7]=> + int(22) + [8]=> + int(33) + [5]=> + int(55) + [6]=> + int(66) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(5) { + [9]=> + int(11) + [7]=> + int(22) + [8]=> + int(33) + [5]=> + int(55) + [6]=> + int(66) +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(3) { + ["c"]=> + string(5) "apple" + [0]=> + string(6) "banana" + ["a"]=> + string(6) "orange" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(3) { + ["c"]=> + string(5) "apple" + [0]=> + string(6) "banana" + ["a"]=> + string(6) "orange" +} + +-- Iteration 3 -- +- With default sort_flag - +bool(true) +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(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) +} + +-- Iteration 4 -- +- With default sort_flag - +bool(true) +array(3) { + [0]=> + string(5) "first" + [5]=> + string(6) "second" + [6]=> + string(5) "third" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(3) { + [0]=> + string(5) "first" + [5]=> + string(6) "second" + [6]=> + string(5) "third" +} + +-- Iteration 5 -- +- With default sort_flag - +bool(true) +array(6) { + [4]=> + int(1) + [0]=> + int(1) + [8]=> + int(1) + [1]=> + int(1) + [3]=> + int(13) + [9]=> + int(19) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(6) { + [4]=> + int(1) + [0]=> + int(1) + [8]=> + int(1) + [1]=> + int(1) + [3]=> + int(13) + [9]=> + int(19) +} + +-- Iteration 6 -- +- With default sort_flag - +bool(true) +array(2) { + ["bar"]=> + string(3) "baz" + ["foo"]=> + int(1) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(2) { + ["bar"]=> + string(3) "baz" + ["foo"]=> + int(1) +} + +-- Iteration 7 -- +- With default sort_flag - +bool(true) +array(4) { + ["a"]=> + int(1) + ["d"]=> + int(5) + ["c"]=> + array(1) { + ["g"]=> + int(4) + } + ["b"]=> + array(2) { + ["e"]=> + int(2) + ["f"]=> + int(3) + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(4) { + ["a"]=> + int(1) + ["d"]=> + int(5) + ["c"]=> + array(1) { + ["g"]=> + int(4) + } + ["b"]=> + array(2) { + ["e"]=> + int(2) + ["f"]=> + int(3) + } +} +Done +--UEXPECTF-- +*** Testing asort() : usage variations *** + +-- Testing asort() by supplying various arrays with key values -- + +-- Iteration 1 -- +- With default sort_flag - +bool(true) +array(5) { + [9]=> + int(11) + [7]=> + int(22) + [8]=> + int(33) + [5]=> + int(55) + [6]=> + int(66) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(5) { + [9]=> + int(11) + [7]=> + int(22) + [8]=> + int(33) + [5]=> + int(55) + [6]=> + int(66) +} + +-- Iteration 2 -- +- With default sort_flag - +bool(true) +array(3) { + [u"c"]=> + unicode(5) "apple" + [0]=> + unicode(6) "banana" + [u"a"]=> + unicode(6) "orange" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(3) { + [u"c"]=> + unicode(5) "apple" + [0]=> + unicode(6) "banana" + [u"a"]=> + unicode(6) "orange" +} + +-- Iteration 3 -- +- With default sort_flag - +bool(true) +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(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) +} + +-- Iteration 4 -- +- With default sort_flag - +bool(true) +array(3) { + [0]=> + unicode(5) "first" + [5]=> + unicode(6) "second" + [6]=> + unicode(5) "third" +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(3) { + [0]=> + unicode(5) "first" + [5]=> + unicode(6) "second" + [6]=> + unicode(5) "third" +} + +-- Iteration 5 -- +- With default sort_flag - +bool(true) +array(6) { + [4]=> + int(1) + [0]=> + int(1) + [8]=> + int(1) + [1]=> + int(1) + [3]=> + int(13) + [9]=> + int(19) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(6) { + [4]=> + int(1) + [0]=> + int(1) + [8]=> + int(1) + [1]=> + int(1) + [3]=> + int(13) + [9]=> + int(19) +} + +-- Iteration 6 -- +- With default sort_flag - +bool(true) +array(2) { + [u"bar"]=> + unicode(3) "baz" + [u"foo"]=> + int(1) +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(2) { + [u"bar"]=> + unicode(3) "baz" + [u"foo"]=> + int(1) +} + +-- Iteration 7 -- +- With default sort_flag - +bool(true) +array(4) { + [u"a"]=> + int(1) + [u"d"]=> + int(5) + [u"c"]=> + array(1) { + [u"g"]=> + int(4) + } + [u"b"]=> + array(2) { + [u"e"]=> + int(2) + [u"f"]=> + int(3) + } +} +- Sort_flag = SORT_REGULAR - +bool(true) +array(4) { + [u"a"]=> + int(1) + [u"d"]=> + int(5) + [u"c"]=> + array(1) { + [u"g"]=> + int(4) + } + [u"b"]=> + array(2) { + [u"e"]=> + int(2) + [u"f"]=> + int(3) + } +} +Done