1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:05:08 +00:00

LibJS: Implement Math.abs()

This commit is contained in:
Andreas Kling 2020-03-29 14:56:28 +02:00
parent 2285f84596
commit 2d3634d5f5
4 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,16 @@
function assert(x) { if (!x) throw 1; }
try {
assert(Math.abs('-1') === 1);
assert(Math.abs(0 - 2) === 2);
assert(Math.abs(null) === 0);
assert(Math.abs('') === 0);
assert(Math.abs([]) === 0);
assert(Math.abs([2]) === 2);
assert(isNaN(Math.abs([1, 2])));
assert(isNaN(Math.abs({})));
assert(isNaN(Math.abs('string')));
assert(isNaN(Math.abs()));
console.log("PASS");
} catch {
}