Arquivos
hhvm/hphp/test/quick/floatcmp.php
T
ptarjan 503f75d08b Rename test directories
These names don't make sense now that we run both suites the same
way.
2013-04-17 09:06:51 -07:00

39 linhas
1.4 KiB
PHP

<?hh
function main() {
$nan = acos(1.01);
$values = array(-0.0, 0.0, 0, 0.0001, $nan, 1.0);
$cmps = array(
function($x, $y) { return $x < $y; },
function($x, $y) { return $x <= $y; },
function($x, $y) { return $x > $y; },
function($x, $y) { return $x >= $y; },
function($x, $y) { return $x == $y; },
function($x, $y) { return $x != $y; },
function($x, $y) { return $x === $y; },
function($x, $y) { return $x !== $y; });
$cmpJmps = array(
function($x, $y) { return $x < $y ? true : false; },
function($x, $y) { return $x <= $y ? true : false; },
function($x, $y) { return $x > $y ? true : false; },
function($x, $y) { return $x >= $y ? true : false; },
function($x, $y) { return $x == $y ? true : false; },
function($x, $y) { return $x != $y ? true : false; },
function($x, $y) { return $x === $y ? true : false; },
function($x, $y) { return $x !== $y ? true : false; });
$cmpNames = array("<", "<=", ">", ">=", "==", "!=", "===", "!==");
foreach ($values as $x) {
foreach ($values as $y) {
echo " ---- $x $y ----\n";
for ($i = 0; $i < sizeof($cmps); $i++) {
var_dump(" $x $cmpNames[$i] $y:", (string)($cmps[$i]($x, $y)));
if ($cmps[$i]($x, $y) !== $cmpJmps[$i]($x, $y)) {
echo "jmps !== cmps, $cmpNames[$i]\n";
}
}
}
}
}
main();