mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibJS: Allow defining class fields with "keyword" names
This commit is contained in:
parent
cbbfcd35e7
commit
e491fc0e81
2 changed files with 49 additions and 3 deletions
|
@ -85,3 +85,45 @@ test("with super class", () => {
|
|||
b.arrow_ref_super();
|
||||
expect(b.super_field).toBe(4);
|
||||
});
|
||||
|
||||
describe("class fields with a 'special' name", () => {
|
||||
test("static", () => {
|
||||
class A {
|
||||
static;
|
||||
}
|
||||
expect("static" in new A()).toBeTrue();
|
||||
|
||||
class B {
|
||||
static;
|
||||
}
|
||||
expect("static" in new B()).toBeTrue();
|
||||
|
||||
class C {
|
||||
static a;
|
||||
}
|
||||
expect("static" in new C()).toBeFalse();
|
||||
expect("a" in new C()).toBeFalse();
|
||||
|
||||
expect("a" in C).toBeTrue();
|
||||
expect("static" in C).toBeFalse();
|
||||
});
|
||||
|
||||
test("async", () => {
|
||||
class A {
|
||||
async;
|
||||
}
|
||||
expect("async" in new A()).toBeTrue();
|
||||
|
||||
class B {
|
||||
async;
|
||||
}
|
||||
expect("async" in new B()).toBeTrue();
|
||||
|
||||
class C {
|
||||
async;
|
||||
a;
|
||||
}
|
||||
expect("async" in new C()).toBeTrue();
|
||||
expect("a" in new C()).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue