1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +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

@ -0,0 +1,69 @@
// This file must not be formatted by prettier. Make sure your IDE
// respects the .prettierignore file!
test("basic functionality", () => {
const A = class {
constructor(x) {
this.x = x;
}
getX() {
return this.x * 2;
}
};
expect(new A(10).getX()).toBe(20);
});
test("inline instantiation", () => {
const a = new class {
constructor() {
this.x = 10;
}
getX() {
return this.x * 2;
}
};
expect(a.getX()).toBe(20);
});
test("inline instantiation with argument", () => {
const a = new class {
constructor(x) {
this.x = x;
}
getX() {
return this.x * 2;
}
}(10);
expect(a.getX()).toBe(20);
});
test("extending class expressions", () => {
class A extends class {
constructor(x) {
this.x = x;
}
} {
constructor(y) {
super(y);
this.y = y * 2;
}
};
const a = new A(10);
expect(a.x).toBe(10);
expect(a.y).toBe(20);
});
test("class expression name", () => {
let A = class {}
expect(A.name).toBe("A");
let B = class C {}
expect(B.name).toBe("C");
});