mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibJS: Add tests for the new steps added to PerformEval
This commit is contained in:
parent
34f902fb52
commit
7798821f5b
5 changed files with 388 additions and 0 deletions
|
@ -111,3 +111,40 @@ test("private identifier not followed by 'in' throws", () => {
|
|||
test("cannot have static and non static field with the same description", () => {
|
||||
expect("class A { static #simple; #simple; }").not.toEval();
|
||||
});
|
||||
|
||||
test("'arguments' is not allowed in class field initializer", () => {
|
||||
expect("class A { #a = arguments; }").not.toEval();
|
||||
expect("class B { static #b = arguments; }").not.toEval();
|
||||
|
||||
class C {
|
||||
#c = eval("arguments");
|
||||
}
|
||||
|
||||
expect(() => {
|
||||
new C();
|
||||
}).toThrowWithMessage(SyntaxError, "'arguments' is not allowed in class field initializer");
|
||||
|
||||
expect(() => {
|
||||
class D {
|
||||
static #d = eval("arguments");
|
||||
}
|
||||
}).toThrowWithMessage(SyntaxError, "'arguments' is not allowed in class field initializer");
|
||||
});
|
||||
|
||||
test("using 'arguments' via indirect eval throws at runtime instead of parse time", () => {
|
||||
const indirect = eval;
|
||||
|
||||
class A {
|
||||
#a = indirect("arguments");
|
||||
}
|
||||
|
||||
expect(() => {
|
||||
new A();
|
||||
}).toThrowWithMessage(ReferenceError, "'arguments' is not defined");
|
||||
|
||||
expect(() => {
|
||||
class B {
|
||||
static #b = indirect("arguments");
|
||||
}
|
||||
}).toThrowWithMessage(ReferenceError, "'arguments' is not defined");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue