summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/builtins/Math/Math.clz32.js
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Tests/builtins/Math/Math.clz32.js')
-rw-r--r--Libraries/LibJS/Tests/builtins/Math/Math.clz32.js90
1 files changed, 42 insertions, 48 deletions
diff --git a/Libraries/LibJS/Tests/builtins/Math/Math.clz32.js b/Libraries/LibJS/Tests/builtins/Math/Math.clz32.js
index ee37c9212d..e80f9f023e 100644
--- a/Libraries/LibJS/Tests/builtins/Math/Math.clz32.js
+++ b/Libraries/LibJS/Tests/builtins/Math/Math.clz32.js
@@ -1,50 +1,44 @@
-load("test-common.js");
+test("basic functionality", () => {
+ expect(Math.clz32).toHaveLength(1);
-try {
- assert(Math.clz32.length === 1);
+ expect(Math.clz32(0)).toBe(32);
+ expect(Math.clz32(1)).toBe(31);
+ expect(Math.clz32(2)).toBe(30);
+ expect(Math.clz32(3)).toBe(30);
+ expect(Math.clz32(4)).toBe(29);
+ expect(Math.clz32(5)).toBe(29);
+ expect(Math.clz32(-1)).toBe(0);
+ expect(Math.clz32(-10)).toBe(0);
+ expect(Math.clz32(-100)).toBe(0);
+ expect(Math.clz32(-1000)).toBe(0);
+ expect(Math.clz32(-0.123)).toBe(32);
+ expect(Math.clz32(0.123)).toBe(32);
+ expect(Math.clz32(1.23)).toBe(31);
+ expect(Math.clz32(12)).toBe(28);
+ expect(Math.clz32(123)).toBe(25);
+ expect(Math.clz32(1234)).toBe(21);
+ expect(Math.clz32(12345)).toBe(18);
+ expect(Math.clz32(123456)).toBe(15);
+ expect(Math.clz32(1234567)).toBe(11);
+ expect(Math.clz32(12345678)).toBe(8);
+ expect(Math.clz32(123456789)).toBe(5);
+ expect(Math.clz32(999999999)).toBe(2);
+ expect(Math.clz32(9999999999)).toBe(1);
+ expect(Math.clz32(99999999999)).toBe(1);
+ expect(Math.clz32(999999999999)).toBe(0);
+ expect(Math.clz32(9999999999999)).toBe(1);
+ expect(Math.clz32(99999999999999)).toBe(3);
+ expect(Math.clz32(999999999999999)).toBe(0);
- 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);
-}
+ expect(Math.clz32()).toBe(32);
+ expect(Math.clz32(NaN)).toBe(32);
+ expect(Math.clz32(Infinity)).toBe(32);
+ expect(Math.clz32(-Infinity)).toBe(32);
+ expect(Math.clz32(false)).toBe(32);
+ expect(Math.clz32(true)).toBe(31);
+ expect(Math.clz32(null)).toBe(32);
+ expect(Math.clz32(undefined)).toBe(32);
+ expect(Math.clz32([])).toBe(32);
+ expect(Math.clz32({})).toBe(32);
+ expect(Math.clz32("foo")).toBe(32);
+});