mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +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
|
@ -86,6 +86,43 @@ test("with super class", () => {
|
|||
expect(b.super_field).toBe(4);
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
describe("class fields with a 'special' name", () => {
|
||||
test("static", () => {
|
||||
class A {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue