1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

LibJS: Reorganize tests into subfolders

This commit is contained in:
Matthew Olsson 2020-07-02 16:09:21 -07:00 committed by Andreas Kling
parent 21064a1883
commit 4c48c9d69d
213 changed files with 10 additions and 2 deletions

View file

@ -0,0 +1,16 @@
load("test-common.js");
try {
assert(isClose(Math.E, 2.718281));
assert(isClose(Math.LN2, 0.693147));
assert(isClose(Math.LN10, 2.302585));
assert(isClose(Math.LOG2E, 1.442695));
assert(isClose(Math.LOG10E, 0.434294));
assert(isClose(Math.PI, 3.1415926));
assert(isClose(Math.SQRT1_2, 0.707106));
assert(isClose(Math.SQRT2, 1.414213));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,16 @@
load("test-common.js");
try {
assert(Math.abs('-1') === 1);
assert(Math.abs(-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 {
}

View file

@ -0,0 +1,13 @@
load("test-common.js");
try {
assert(isNaN(Math.acosh(-1)));
assert(isNaN(Math.acosh(0)));
assert(isNaN(Math.acosh(0.5)));
assert(isClose(Math.acosh(1), 0));
// FIXME: assert(isClose(Math.acosh(2), 1.316957));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,11 @@
load("test-common.js");
try {
assert(isClose(Math.asinh(0), 0));
// FIXME: assert(isClose(Math.asinh(1), 0.881373));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,14 @@
load("test-common.js");
try {
assert(isNaN(Math.atanh(-2)));
assert(Math.atanh(-1) === -Infinity);
// FIXME: assert(Math.atanh(0) === 0);
assert(isClose(Math.atanh(0.5), 0.549306));
// FIXME: assert(Math.atanh(1) === Infinity);
assert(isNaN(Math.atanh(2)));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,16 @@
load("test-common.js");
try {
assert(isNaN(Math.cbrt(NaN)));
// FIXME: assert(Math.cbrt(-1) === -1);
assert(Math.cbrt(-0) === -0);
// FIXME: assert(Math.cbrt(-Infinity) === -Infinity);
// FIXME: assert(Math.cbrt(1) === 1);
// FIXME: assert(Math.cbrt(Infinity) === Infinity);
assert(Math.cbrt(null) === 0);
// FIXME: assert(isClose(Math.cbrt(2), 1.259921));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,19 @@
load("test-common.js");
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);
}

View file

@ -0,0 +1,50 @@
load("test-common.js");
try {
assert(Math.clz32.length === 1);
assert(Math.clz32(0) === 32);
assert(Math.clz32(1) === 31);
assert(Math.clz32(2) === 30);
assert(Math.clz32(3) === 30);
assert(Math.clz32(4) === 29);
assert(Math.clz32(5) === 29);
assert(Math.clz32(-1) === 0);
assert(Math.clz32(-10) === 0);
assert(Math.clz32(-100) === 0);
assert(Math.clz32(-1000) === 0);
assert(Math.clz32(-0.123) === 32);
assert(Math.clz32(0.123) === 32);
assert(Math.clz32(1.23) === 31);
assert(Math.clz32(12) === 28);
assert(Math.clz32(123) === 25);
assert(Math.clz32(1234) === 21);
assert(Math.clz32(12345) === 18);
assert(Math.clz32(123456) === 15);
assert(Math.clz32(1234567) === 11);
assert(Math.clz32(12345678) === 8);
assert(Math.clz32(123456789) === 5);
assert(Math.clz32(999999999) === 2);
assert(Math.clz32(9999999999) === 1);
assert(Math.clz32(99999999999) === 1);
assert(Math.clz32(999999999999) === 0);
assert(Math.clz32(9999999999999) === 1);
assert(Math.clz32(99999999999999) === 3);
assert(Math.clz32(999999999999999) === 0);
assert(Math.clz32() === 32);
assert(Math.clz32(NaN) === 32);
assert(Math.clz32(Infinity) === 32);
assert(Math.clz32(-Infinity) === 32);
assert(Math.clz32(false) === 32);
assert(Math.clz32(true) === 31);
assert(Math.clz32(null) === 32);
assert(Math.clz32(undefined) === 32);
assert(Math.clz32([]) === 32);
assert(Math.clz32({}) === 32);
assert(Math.clz32("foo") === 32);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,18 @@
load("test-common.js");
try {
assert(Math.cos(0) === 1);
assert(Math.cos(null) === 1);
assert(Math.cos('') === 1);
assert(Math.cos([]) === 1);
assert(Math.cos(Math.PI) === -1);
assert(isNaN(Math.cos()));
assert(isNaN(Math.cos(undefined)));
assert(isNaN(Math.cos([1, 2, 3])));
assert(isNaN(Math.cos({})));
assert(isNaN(Math.cos("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,19 @@
load("test-common.js");
try {
assert(Math.exp.length === 1);
assert(Math.exp(0) === 1);
assert(isClose(Math.exp(-2), 0.135335));
assert(isClose(Math.exp(-1), 0.367879));
assert(isClose(Math.exp(1), 2.718281));
assert(isClose(Math.exp(2), 7.389056));
assert(isNaN(Math.exp()));
assert(isNaN(Math.exp(undefined)));
assert(isNaN(Math.exp("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,19 @@
load("test-common.js");
try {
assert(Math.expm1.length === 1);
assert(Math.expm1(0) === 0);
assert(isClose(Math.expm1(-2), -0.864664));
assert(isClose(Math.expm1(-1), -0.632120));
assert(isClose(Math.expm1(1), 1.718281));
assert(isClose(Math.expm1(2), 6.389056));
assert(isNaN(Math.expm1()));
assert(isNaN(Math.expm1(undefined)));
assert(isNaN(Math.expm1("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,19 @@
load("test-common.js");
try {
assert(Math.floor(0.95) === 0);
assert(Math.floor(4) === 4);
assert(Math.floor(7.004) == 7);
assert(Math.floor(-0.95) === -1);
assert(Math.floor(-4) === -4);
assert(Math.floor(-7.004) === -8);
assert(isNaN(Math.floor()));
assert(isNaN(Math.floor(NaN)));
assert(Math.floor.length === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,13 @@
load("test-common.js");
try {
assert(isNaN(Math.log1p(-2)));
assert(Math.log1p(-1) === -Infinity);
// FIXME: assert(Math.log1p(0) === 0);
// FIXME: assert(isClose(Math.log1p(1), 0.693147));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,15 @@
load("test-common.js");
try {
assert(Math.max.length === 2);
assert(Math.max() === -Infinity);
assert(Math.max(1) === 1);
assert(Math.max(2, 1) === 2);
assert(Math.max(1, 2, 3) === 3);
assert(isNaN(Math.max(NaN)));
assert(isNaN(Math.max("String", 1)));
console.log("PASS");
} catch {
console.log("FAIL");
}

View file

@ -0,0 +1,14 @@
load("test-common.js");
try {
assert(Math.min.length === 2);
assert(Math.min(1) === 1);
assert(Math.min(2, 1) === 1);
assert(Math.min(1, 2, 3) === 1);
assert(isNaN(Math.min(NaN)));
assert(isNaN(Math.min("String", 1)));
console.log("PASS");
} catch {
console.log("FAIL");
}

View file

@ -0,0 +1,29 @@
load("test-common.js");
try {
assert(Math.pow(2, 0) === 1);
assert(Math.pow(2, 1) === 2);
assert(Math.pow(2, 2) === 4);
assert(Math.pow(2, 3) === 8);
assert(Math.pow(2, -3) === 0.125);
assert(Math.pow(3, 2) === 9);
assert(Math.pow(0, 0) === 1);
assert(Math.pow(2, Math.pow(3, 2)) === 512);
assert(Math.pow(Math.pow(2, 3), 2) === 64);
assert(Math.pow("2", "3") === 8);
assert(Math.pow("", []) === 1);
assert(Math.pow([], null) === 1);
assert(Math.pow(null, null) === 1);
assert(Math.pow(undefined, null) === 1);
assert(isNaN(Math.pow(NaN, 2)));
assert(isNaN(Math.pow(2, NaN)));
assert(isNaN(Math.pow(undefined, 2)));
assert(isNaN(Math.pow(2, undefined)));
assert(isNaN(Math.pow(null, undefined)));
assert(isNaN(Math.pow(2, "foo")));
assert(isNaN(Math.pow("foo", 2)));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View 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);
}

View file

@ -0,0 +1,19 @@
load("test-common.js");
try {
assert(Math.sin(0) === 0);
assert(Math.sin(null) === 0);
assert(Math.sin('') === 0);
assert(Math.sin([]) === 0);
assert(Math.sin(Math.PI * 3 / 2) === -1);
assert(Math.sin(Math.PI / 2) === 1);
assert(isNaN(Math.sin()));
assert(isNaN(Math.sin(undefined)));
assert(isNaN(Math.sin([1, 2, 3])));
assert(isNaN(Math.sin({})));
assert(isNaN(Math.sin("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,7 @@
load("test-common.js");
try {
assert(Math.sqrt(9) === 3);
console.log("PASS");
} catch {
}

View file

@ -0,0 +1,18 @@
load("test-common.js");
try {
assert(Math.tan(0) === 0);
assert(Math.tan(null) === 0);
assert(Math.tan('') === 0);
assert(Math.tan([]) === 0);
assert(Math.ceil(Math.tan(Math.PI / 4)) === 1);
assert(isNaN(Math.tan()));
assert(isNaN(Math.tan(undefined)));
assert(isNaN(Math.tan([1, 2, 3])));
assert(isNaN(Math.tan({})));
assert(isNaN(Math.tan("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,18 @@
load("test-common.js")
try {
assert(Math.trunc(13.37) === 13);
assert(Math.trunc(42.84) === 42);
assert(Math.trunc(0.123) === 0);
assert(Math.trunc(-0.123) === -0);
assert(isNaN(Math.trunc(NaN)));
assert(isNaN(Math.trunc('foo')));
assert(isNaN(Math.trunc()));
assert(Math.trunc.length === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}