Everywhere: Hoist the Libraries folder to the top-level

This commit is contained in:
Timothy Flynn 2024-11-09 12:25:08 -05:00 committed by Andreas Kling
commit 93712b24bf
Notes: github-actions[bot] 2024-11-10 11:51:52 +00:00
4547 changed files with 104 additions and 113 deletions

View file

@ -0,0 +1,61 @@
test("basic functionality", () => {
function foo() {
return new.target;
}
expect(foo()).toBeUndefined();
expect(new foo()).toEqual(foo);
function bar() {
const baz = () => new.target;
return baz();
}
expect(bar()).toBeUndefined();
expect(new bar()).toEqual(bar);
class baz {
constructor() {
this.newTarget = new.target;
}
}
expect(new baz().newTarget).toEqual(baz);
});
test("retrieving new.target from direct eval", () => {
function foo() {
return eval("new.target");
}
let result;
expect(() => {
result = foo();
}).not.toThrowWithMessage(SyntaxError, "'new.target' not allowed outside of a function");
expect(result).toBe(undefined);
expect(() => {
result = new foo();
}).not.toThrowWithMessage(SyntaxError, "'new.target' not allowed outside of a function");
expect(result).toBe(foo);
});
test("cannot retrieve new.target from indirect eval", () => {
const indirect = eval;
function foo() {
return indirect("new.target");
}
expect(() => {
foo();
}).toThrowWithMessage(SyntaxError, "'new.target' not allowed outside of a function");
expect(() => {
new foo();
}).toThrowWithMessage(SyntaxError, "'new.target' not allowed outside of a function");
});
test("syntax error outside of function", () => {
expect("new.target").not.toEval();
});