1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 09:42:22 +01:00
Files
archived-php-src/ext/standard/tests/array/usort_variation11.phpt
Xinchen Hui 020b51b46e Don't use >= as sorting condition
which could avoid breaking usage like:

usort($a, function($a, $b) { return $a > $b; })
2015-01-19 01:36:56 -05:00

26 lines
453 B
PHP

--TEST--
Test usort() function : usage variations - binary return cmp
--FILE--
<?php
function ucmp($a, $b) {
return $a > $b;
}
$range = array(2, 4, 8, 16, 32, 64, 128);
foreach ($range as $r) {
$backup = $array = range(0, $r);
shuffle($array);
usort($array, "ucmp");
if ($array != $backup) {
var_dump($array);
var_dump($backup);
die("Whatever sorting algo you used, this test should never be broken");
}
}
echo "okey";
?>
--EXPECT--
okey