summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/builtins/Number
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Tests/builtins/Number')
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number-constants.js11
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.isFinite.js24
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.isInteger.js32
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.isNaN.js25
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.isSafeInteger.js24
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.js33
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.parseFloat.js5
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.prototype.js4
-rw-r--r--Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js83
9 files changed, 0 insertions, 241 deletions
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number-constants.js b/Libraries/LibJS/Tests/builtins/Number/Number-constants.js
deleted file mode 100644
index 2958821546..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number-constants.js
+++ /dev/null
@@ -1,11 +0,0 @@
-test("basic functionality", () => {
- expect(Number.EPSILON).toBe(2 ** -52);
- expect(Number.EPSILON).toBeGreaterThan(0);
- expect(Number.MAX_SAFE_INTEGER).toBe(2 ** 53 - 1);
- expect(Number.MAX_SAFE_INTEGER + 1).toBe(Number.MAX_SAFE_INTEGER + 2);
- expect(Number.MIN_SAFE_INTEGER).toBe(-(2 ** 53 - 1));
- expect(Number.MIN_SAFE_INTEGER - 1).toBe(Number.MIN_SAFE_INTEGER - 2);
- expect(Number.POSITIVE_INFINITY).toBe(Infinity);
- expect(Number.NEGATIVE_INFINITY).toBe(-Infinity);
- expect(Number.NaN).toBeNaN();
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.isFinite.js b/Libraries/LibJS/Tests/builtins/Number/Number.isFinite.js
deleted file mode 100644
index 19a23c0292..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.isFinite.js
+++ /dev/null
@@ -1,24 +0,0 @@
-test("basic functionality", () => {
- expect(Number.isFinite).toHaveLength(1);
- expect(Number.isFinite).not.toBe(isFinite);
-
- expect(Number.isFinite(0)).toBeTrue();
- expect(Number.isFinite(1.23)).toBeTrue();
- expect(Number.isFinite(42)).toBeTrue();
-
- expect(Number.isFinite("")).toBeFalse();
- expect(Number.isFinite("0")).toBeFalse();
- expect(Number.isFinite("42")).toBeFalse();
- expect(Number.isFinite(true)).toBeFalse();
- expect(Number.isFinite(false)).toBeFalse();
- expect(Number.isFinite(null)).toBeFalse();
- expect(Number.isFinite([])).toBeFalse();
- expect(Number.isFinite()).toBeFalse();
- expect(Number.isFinite(NaN)).toBeFalse();
- expect(Number.isFinite(undefined)).toBeFalse();
- expect(Number.isFinite(Infinity)).toBeFalse();
- expect(Number.isFinite(-Infinity)).toBeFalse();
- expect(Number.isFinite("foo")).toBeFalse();
- expect(Number.isFinite({})).toBeFalse();
- expect(Number.isFinite([1, 2, 3])).toBeFalse();
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.isInteger.js b/Libraries/LibJS/Tests/builtins/Number/Number.isInteger.js
deleted file mode 100644
index ff0bc9370c..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.isInteger.js
+++ /dev/null
@@ -1,32 +0,0 @@
-test("basic functionality", () => {
- expect(Number.isInteger).toHaveLength(1);
-
- expect(Number.isInteger(0)).toBeTrue();
- expect(Number.isInteger(42)).toBeTrue();
- expect(Number.isInteger(-10000)).toBeTrue();
- expect(Number.isInteger(5)).toBeTrue();
- expect(Number.isInteger(5.0)).toBeTrue();
- expect(Number.isInteger(5 + 1 / 10000000000000000)).toBeTrue();
- // FIXME: values outside of i32's range should still return true
- // expect(Number.isInteger(+2147483647 + 1)).toBeTrue();
- // expect(Number.isInteger(-2147483648 - 1)).toBeTrue();
- // expect(Number.isInteger(99999999999999999999999999999999999)).toBeTrue();
-
- expect(Number.isInteger(5 + 1 / 1000000000000000)).toBeFalse();
- expect(Number.isInteger(1.23)).toBeFalse();
- expect(Number.isInteger("")).toBeFalse();
- expect(Number.isInteger("0")).toBeFalse();
- expect(Number.isInteger("42")).toBeFalse();
- expect(Number.isInteger(true)).toBeFalse();
- expect(Number.isInteger(false)).toBeFalse();
- expect(Number.isInteger(null)).toBeFalse();
- expect(Number.isInteger([])).toBeFalse();
- expect(Number.isInteger(Infinity)).toBeFalse();
- expect(Number.isInteger(-Infinity)).toBeFalse();
- expect(Number.isInteger(NaN)).toBeFalse();
- expect(Number.isInteger()).toBeFalse();
- expect(Number.isInteger(undefined)).toBeFalse();
- expect(Number.isInteger("foo")).toBeFalse();
- expect(Number.isInteger({})).toBeFalse();
- expect(Number.isInteger([1, 2, 3])).toBeFalse();
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.isNaN.js b/Libraries/LibJS/Tests/builtins/Number/Number.isNaN.js
deleted file mode 100644
index 6a7df463df..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.isNaN.js
+++ /dev/null
@@ -1,25 +0,0 @@
-test("basic functionality", () => {
- expect(Number.isNaN).toHaveLength(1);
- expect(Number.isNaN).not.toBe(isNaN);
-
- expect(Number.isNaN(0)).toBeFalse();
- expect(Number.isNaN(42)).toBeFalse();
- expect(Number.isNaN("")).toBeFalse();
- expect(Number.isNaN("0")).toBeFalse();
- expect(Number.isNaN("42")).toBeFalse();
- expect(Number.isNaN(true)).toBeFalse();
- expect(Number.isNaN(false)).toBeFalse();
- expect(Number.isNaN(null)).toBeFalse();
- expect(Number.isNaN([])).toBeFalse();
- expect(Number.isNaN(Infinity)).toBeFalse();
- expect(Number.isNaN(-Infinity)).toBeFalse();
- expect(Number.isNaN()).toBeFalse();
- expect(Number.isNaN(undefined)).toBeFalse();
- expect(Number.isNaN("foo")).toBeFalse();
- expect(Number.isNaN({})).toBeFalse();
- expect(Number.isNaN([1, 2, 3])).toBeFalse();
-
- expect(Number.isNaN(NaN)).toBeTrue();
- expect(Number.isNaN(Number.NaN)).toBeTrue();
- expect(Number.isNaN(0 / 0)).toBeTrue();
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.isSafeInteger.js b/Libraries/LibJS/Tests/builtins/Number/Number.isSafeInteger.js
deleted file mode 100644
index 3bba1682a6..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.isSafeInteger.js
+++ /dev/null
@@ -1,24 +0,0 @@
-test("basic functionality", () => {
- expect(Number.isSafeInteger).toHaveLength(1);
-
- expect(Number.isSafeInteger(0)).toBeTrue();
- expect(Number.isSafeInteger(1)).toBeTrue();
- expect(Number.isSafeInteger(2.0)).toBeTrue();
- expect(Number.isSafeInteger(42)).toBeTrue();
- expect(Number.isSafeInteger(Number.MAX_SAFE_INTEGER)).toBeTrue();
- expect(Number.isSafeInteger(Number.MIN_SAFE_INTEGER)).toBeTrue();
-
- expect(Number.isSafeInteger()).toBeFalse();
- expect(Number.isSafeInteger("1")).toBeFalse();
- expect(Number.isSafeInteger(2.1)).toBeFalse();
- expect(Number.isSafeInteger(42.42)).toBeFalse();
- expect(Number.isSafeInteger("")).toBeFalse();
- expect(Number.isSafeInteger([])).toBeFalse();
- expect(Number.isSafeInteger(null)).toBeFalse();
- expect(Number.isSafeInteger(undefined)).toBeFalse();
- expect(Number.isSafeInteger(NaN)).toBeFalse();
- expect(Number.isSafeInteger(Infinity)).toBeFalse();
- expect(Number.isSafeInteger(-Infinity)).toBeFalse();
- expect(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1)).toBeFalse();
- expect(Number.isSafeInteger(Number.MIN_SAFE_INTEGER - 1)).toBeFalse();
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.js b/Libraries/LibJS/Tests/builtins/Number/Number.js
deleted file mode 100644
index 7fd7067449..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.js
+++ /dev/null
@@ -1,33 +0,0 @@
-test("basic functionality", () => {
- expect(Number).toHaveLength(1);
- expect(Number.name).toBe("Number");
- expect(Number.prototype).not.toHaveProperty("length");
-
- expect(typeof Number()).toBe("number");
- expect(typeof new Number()).toBe("object");
-
- expect(Number()).toBe(0);
- expect(new Number().valueOf()).toBe(0);
- expect(Number("42")).toBe(42);
- expect(new Number("42").valueOf()).toBe(42);
- expect(Number(null)).toBe(0);
- expect(new Number(null).valueOf()).toBe(0);
- expect(Number(true)).toBe(1);
- expect(new Number(true).valueOf()).toBe(1);
- expect(Number("Infinity")).toBe(Infinity);
- expect(new Number("Infinity").valueOf()).toBe(Infinity);
- expect(Number("+Infinity")).toBe(Infinity);
- expect(new Number("+Infinity").valueOf()).toBe(Infinity);
- expect(Number("-Infinity")).toBe(-Infinity);
- expect(new Number("-Infinity").valueOf()).toBe(-Infinity);
- expect(Number(undefined)).toBeNaN();
- expect(new Number(undefined).valueOf()).toBeNaN();
- expect(Number({})).toBeNaN();
- expect(new Number({}).valueOf()).toBeNaN();
- expect(Number({ a: 1 })).toBeNaN();
- expect(new Number({ a: 1 }).valueOf()).toBeNaN();
- expect(Number([1, 2, 3])).toBeNaN();
- expect(new Number([1, 2, 3]).valueOf()).toBeNaN();
- expect(Number("foo")).toBeNaN();
- expect(new Number("foo").valueOf()).toBeNaN();
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.parseFloat.js b/Libraries/LibJS/Tests/builtins/Number/Number.parseFloat.js
deleted file mode 100644
index 89de9ff0d9..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.parseFloat.js
+++ /dev/null
@@ -1,5 +0,0 @@
-test("basic functionality", () => {
- // Ensuring it's the same function as the global
- // parseFloat() is enough as that already has tests :^)
- expect(Number.parseFloat).toBe(parseFloat);
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.prototype.js b/Libraries/LibJS/Tests/builtins/Number/Number.prototype.js
deleted file mode 100644
index 91f2e93c0e..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.prototype.js
+++ /dev/null
@@ -1,4 +0,0 @@
-test("basic functionality", () => {
- expect(typeof Number.prototype).toBe("object");
- expect(Number.prototype.valueOf()).toBe(0);
-});
diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js b/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js
deleted file mode 100644
index c07ca792f6..0000000000
--- a/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js
+++ /dev/null
@@ -1,83 +0,0 @@
-describe("correct behavior", () => {
- test("length", () => {
- expect(Number.prototype.toString).toHaveLength(1);
- });
-
- test("basic functionality", () => {
- [
- [+0, "0"],
- [-0, "0"],
- [Infinity, "Infinity"],
- [-Infinity, "-Infinity"],
- [NaN, "NaN"],
- [12, "12"],
- [93465, "93465"],
- [358000, "358000"],
- ].forEach(testCase => {
- expect(testCase[0].toString()).toBe(testCase[1]);
- });
- });
-
- test("radix", () => {
- let number = 7857632;
-
- [
- [2, "11101111110010111100000"],
- [3, "112210012122102"],
- [4, "131332113200"],
- [5, "4002421012"],
- [6, "440225532"],
- [7, "123534356"],
- [8, "35762740"],
- [9, "15705572"],
- [10, "7857632"],
- [11, "4487612"],
- [12, "276b2a8"],
- [13, "18216b3"],
- [14, "10877d6"],
- [15, "a532c2"],
- [16, "77e5e0"],
- [17, "59160b"],
- [18, "42f5h2"],
- [19, "335b5b"],
- [20, "29241c"],
- [21, "1j89fk"],
- [22, "1bbkh2"],
- [23, "151ih4"],
- [24, "ng9h8"],
- [25, "k2m57"],
- [26, "h51ig"],
- [27, "el5hb"],
- [28, "clqdk"],
- [29, "b355o"],
- [30, "9l0l2"],
- [31, "8fng0"],
- [32, "7fpf0"],
- [33, "6klf2"],
- [34, "5tv8s"],
- [35, "589dr"],
- [36, "4oezk"],
- ].forEach(testCase => {
- expect(number.toString(testCase[0])).toBe(testCase[1]);
- });
- });
-
- test("decimal radix gets converted to int", () => {
- expect((30).toString(10.1)).toBe("30");
- expect((30).toString(10.9)).toBe("30");
- });
-});
-
-test("errors", () => {
- test("must be called with numeric |this|", () => {
- [true, [], {}, Symbol("foo"), "bar", 1n].forEach(value => {
- expect(() => Number.prototype.toString.call(value)).toThrow(TypeError);
- });
- });
-
- test("radix RangeError", () => {
- [0, 1, 37, 100].forEach(value => {
- expect(() => (0).toString(value)).toThrow(RangeError);
- });
- });
-});