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:
parent
2285f84596
commit
2d3634d5f5
4 changed files with 46 additions and 1 deletions
16
Libraries/LibJS/Tests/Math.abs.js
Normal file
16
Libraries/LibJS/Tests/Math.abs.js
Normal 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 {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue