mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibJS: Reorganize tests into subfolders
This commit is contained in:
parent
21064a1883
commit
4c48c9d69d
213 changed files with 10 additions and 2 deletions
42
Libraries/LibJS/Tests/builtins/Math/Math.sign.js
Normal file
42
Libraries/LibJS/Tests/builtins/Math/Math.sign.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
load("test-common.js");
|
||||
|
||||
function isPositiveZero(value) {
|
||||
return value === 0 && 1 / value === Infinity;
|
||||
}
|
||||
|
||||
function isNegativeZero(value) {
|
||||
return value === 0 && 1 / value === -Infinity;
|
||||
}
|
||||
|
||||
try {
|
||||
assert(Math.sign.length === 1);
|
||||
|
||||
assert(Math.sign(0.0001) === 1);
|
||||
assert(Math.sign(1) === 1);
|
||||
assert(Math.sign(42) === 1);
|
||||
assert(Math.sign(Infinity) === 1);
|
||||
assert(isPositiveZero(Math.sign(0)));
|
||||
assert(isPositiveZero(Math.sign(null)));
|
||||
assert(isPositiveZero(Math.sign('')));
|
||||
assert(isPositiveZero(Math.sign([])));
|
||||
|
||||
assert(Math.sign(-0.0001) === -1);
|
||||
assert(Math.sign(-1) === -1);
|
||||
assert(Math.sign(-42) === -1);
|
||||
assert(Math.sign(-Infinity) === -1);
|
||||
assert(isNegativeZero(Math.sign(-0)));
|
||||
assert(isNegativeZero(Math.sign(-null)));
|
||||
assert(isNegativeZero(Math.sign(-'')));
|
||||
assert(isNegativeZero(Math.sign(-[])));
|
||||
|
||||
assert(isNaN(Math.sign()));
|
||||
assert(isNaN(Math.sign(undefined)));
|
||||
assert(isNaN(Math.sign([1, 2, 3])));
|
||||
assert(isNaN(Math.sign({})));
|
||||
assert(isNaN(Math.sign(NaN)));
|
||||
assert(isNaN(Math.sign("foo")));
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue