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

LibJS: Allow super property lookup and new.target in static init blocks

This commit is contained in:
davidot 2021-12-19 02:06:22 +01:00 committed by Linus Groh
parent 92672b1520
commit 45578f58dc
2 changed files with 28 additions and 1 deletions

View file

@ -46,3 +46,29 @@ test("correct this", () => {
expect(thisValue).toBe(A);
});
describe("class like constructs can be used inside", () => {
test("can use new.target", () => {
let value = 1;
class C {
static {
value = new.target;
}
}
expect(value).toBeUndefined();
});
test("can use super property lookup", () => {
function parent() {}
parent.val = 3;
let hit = false;
class C extends parent {
static {
hit = true;
expect(super.val).toBe(3);
}
}
expect(hit).toBeTrue();
});
});