test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

50 lines
1.6 KiB
JavaScript

function canSimplifyToFloat(a, b)
{
return Math.fround(a) === Math.fround(b);
}
noInline(canSimplifyToFloat);
function canSimplifyToFloatWithConstant(a)
{
return Math.fround(a) === 1.0;
}
noInline(canSimplifyToFloatWithConstant);
function cannotSimplifyA(a, b)
{
return a === Math.fround(b);
}
noInline(cannotSimplifyA);
function cannotSimplifyB(a, b)
{
return Math.fround(a) === b;
}
noInline(cannotSimplifyB);
for (let i = 1; i < 1e4; ++i) {
if (canSimplifyToFloat(Math.PI, Math.PI) !== true)
throw "Failed canSimplifyToFloat(Math.PI, Math.PI)";
if (canSimplifyToFloat(Math.LN2, Math.PI) !== false)
throw "Failed canSimplifyToFloat(Math.LN2, Math.PI)";
if (canSimplifyToFloatWithConstant(Math.PI) !== false)
throw "Failed canSimplifyToFloatWithConstant(Math.PI)";
if (canSimplifyToFloatWithConstant(1) !== true)
throw "Failed canSimplifyToFloatWithConstant(1)";
if (cannotSimplifyA(Math.PI, Math.PI) !== false)
throw "Failed cannotSimplifyA(Math.PI, Math.PI)";
if (cannotSimplifyA(Math.fround(Math.PI), Math.PI) !== true)
throw "Failed cannotSimplifyA(Math.round(Math.PI), Math.PI)";
if (cannotSimplifyA(Math.LN2, Math.PI) !== false)
throw "Failed cannotSimplifyA(Math.LN2, Math.PI)";
if (cannotSimplifyB(Math.PI, Math.PI) !== false)
throw "Failed cannotSimplifyA(Math.PI, Math.PI)";
if (cannotSimplifyB(Math.PI, Math.fround(Math.PI)) !== true)
throw "Failed cannotSimplifyA(Math.round(Math.PI), Math.PI)";
if (cannotSimplifyB(Math.LN2, Math.PI) !== false)
throw "Failed cannotSimplifyA(Math.LN2, Math.PI)";
}