mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibJS: Replace the verify in private identifier with a syntax error
Since sometimes expressions are parsed without checking we can hit this expression without it being followed by an 'in'.
This commit is contained in:
parent
b7c7d54167
commit
c2ebaa9d87
2 changed files with 15 additions and 2 deletions
|
@ -96,6 +96,18 @@ test("slash after private identifier is treated as division", () => {
|
|||
expect(A.getDivided()).toBe(2);
|
||||
});
|
||||
|
||||
test("private identifier not followed by 'in' throws", () => {
|
||||
expect(`class A { #field = 2; method() { return #field instanceof 1; }}`).not.toEval();
|
||||
expect(`class A { #field = 2; method() { return #field < 1; }}`).not.toEval();
|
||||
expect(`class A { #field = 2; method() { return #field + 1; }}`).not.toEval();
|
||||
expect(`class A { #field = 2; method() { return #field ** 1; }}`).not.toEval();
|
||||
expect(`class A { #field = 2; method() { return !#field; } }`).not.toEval();
|
||||
expect(`class A { #field = 2; method() { return ~#field; } }`).not.toEval();
|
||||
expect(`class A { #field = 2; method() { return ++#field; } }`).not.toEval();
|
||||
|
||||
expect(`class A { #field = 2; method() { return #field in 1; }}`).toEval();
|
||||
});
|
||||
|
||||
test("cannot have static and non static field with the same description", () => {
|
||||
expect("class A { static #simple; #simple; }").not.toEval();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue