mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
61
Libraries/LibJS/Tests/functions/function-new-target.js
Normal file
61
Libraries/LibJS/Tests/functions/function-new-target.js
Normal 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();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue