mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
88 lines
1.4 KiB
JavaScript
88 lines
1.4 KiB
JavaScript
function shouldThrowTDZ(func) {
|
|
var hasThrown = false;
|
|
try {
|
|
func();
|
|
} catch(e) {
|
|
hasThrown = e instanceof ReferenceError;
|
|
}
|
|
if (!hasThrown)
|
|
throw new Error("Did not throw TDZ error");
|
|
}
|
|
|
|
function test(f, n = 1000) {
|
|
for (let i = 0; i < n; i++)
|
|
f();
|
|
}
|
|
|
|
test(function() {
|
|
function foo() {
|
|
eval("20");
|
|
let eval;
|
|
}
|
|
shouldThrowTDZ(foo);
|
|
});
|
|
|
|
test(function() {
|
|
function foo() {
|
|
eval("20");
|
|
let {eval} = {eval:450};
|
|
}
|
|
shouldThrowTDZ(foo);
|
|
});
|
|
|
|
test(function() {
|
|
function foo() {
|
|
eval("20");
|
|
const eval = 45;
|
|
}
|
|
shouldThrowTDZ(foo);
|
|
});
|
|
|
|
test(function() {
|
|
function foo() {
|
|
eval("20");
|
|
}
|
|
shouldThrowTDZ(foo);
|
|
let eval;
|
|
});
|
|
|
|
test(function() {
|
|
function foo() {
|
|
eval("20");
|
|
}
|
|
shouldThrowTDZ(foo);
|
|
let {eval} = {eval:450};
|
|
});
|
|
|
|
test(function() {
|
|
function foo() {
|
|
eval("20");
|
|
}
|
|
shouldThrowTDZ(foo);
|
|
const eval = 45;
|
|
});
|
|
|
|
{
|
|
let threw = false;
|
|
try {
|
|
eval(20);
|
|
let eval;
|
|
} catch(e) {
|
|
threw = e instanceof ReferenceError;
|
|
}
|
|
if (!threw)
|
|
throw new Error("Bad")
|
|
}
|
|
|
|
{
|
|
let threw = false;
|
|
try {
|
|
eval(20);
|
|
const eval = 25;
|
|
} catch(e) {
|
|
threw = e instanceof ReferenceError;
|
|
}
|
|
if (!threw)
|
|
throw new Error("Bad")
|
|
}
|