1 // new.target is valid in any arrow function not in a global context.
2 new Function('(() => new.target)()');
4 // It's also good inside eval, but not global eval
5 assertThrowsInstanceOf(() => eval('() => new.target'), SyntaxError);
7 function assertNewTarget(expected) {
8 assertEq((()=>new.target)(), expected);
9 assertEq(eval('()=>new.target')(), expected);
11 // Make sure that arrow functions can escape their original context and
12 // still get the right answer.
13 return (() => new.target);
16 const ITERATIONS = 550;
17 for (let i = 0; i < ITERATIONS; i++)
18 assertEq(assertNewTarget(undefined)(), undefined);
20 for (let i = 0; i < ITERATIONS; i++)
21 assertEq(new assertNewTarget(assertNewTarget)(), assertNewTarget);
23 if (typeof reportCompare === 'function')
24 reportCompare(0,0,"OK");