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

LibJS: Convert all remaining non-Array tests to the new system :)

This commit is contained in:
Matthew Olsson 2020-07-05 17:26:26 -07:00 committed by Andreas Kling
parent 918f4affd5
commit 15de2eda2b
72 changed files with 2394 additions and 1998 deletions

View file

@ -1,27 +1,23 @@
load("test-common.js");
try {
test("basic functionality", () => {
function foo() {}
assert(foo.length === 0);
assert((foo.length = 5) === 5);
assert(foo.length === 0);
expect(foo).toHaveLength(0);
expect((foo.length = 5)).toBe(5);
expect(foo).toHaveLength(0);
function bar(a, b, c) {}
assert(bar.length === 3);
assert((bar.length = 5) === 5);
assert(bar.length === 3);
expect(bar).toHaveLength(3);
expect((bar.length = 5)).toBe(5);
expect(bar).toHaveLength(3);
});
test("functions with special parameter lists", () => {
function baz(a, b = 1, c) {}
assert(baz.length === 1);
assert((baz.length = 5) === 5);
assert(baz.length === 1);
expect(baz).toHaveLength(1);
expect((baz.length = 5)).toBe(5);
expect(baz).toHaveLength(1);
function qux(a, b, ...c) {}
assert(qux.length === 2);
assert((qux.length = 5) === 5);
assert(qux.length === 2);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(qux).toHaveLength(2);
expect((qux.length = 2)).toBe(2);
expect(qux).toHaveLength(2);
});