mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
LibJS: Convert most builtin tests to new system
This commit is contained in:
parent
46581773c1
commit
3f97d75778
107 changed files with 2031 additions and 2243 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue