mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 11:05:09 +00:00

Introduce support for the both of these Math methods. Math.trunc is implemented in terms of Math.ceil or Math.floor based on the input value. Added tests as well.
19 lines
439 B
JavaScript
19 lines
439 B
JavaScript
function assert(x) { if (!x) throw 1; }
|
|
|
|
try {
|
|
assert(Math.ceil(0.95) === 1);
|
|
assert(Math.ceil(4) === 4);
|
|
assert(Math.ceil(7.004) == 8);
|
|
assert(Math.ceil(-0.95) === -0);
|
|
assert(Math.ceil(-4) === -4);
|
|
assert(Math.ceil(-7.004) === -7);
|
|
|
|
assert(isNaN(Math.ceil()));
|
|
assert(isNaN(Math.ceil(NaN)));
|
|
|
|
assert(Math.ceil.length === 1);
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|