mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 14:30:27 +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)
37 lines
801 B
JavaScript
37 lines
801 B
JavaScript
function assert(b) {
|
|
if (!b)
|
|
throw new Error("Bad assertion")
|
|
}
|
|
noInline(assert);
|
|
|
|
function shouldThrowTDZ(func) {
|
|
var hasThrown = false;
|
|
try {
|
|
func();
|
|
} catch(e) {
|
|
if (e.name.indexOf("ReferenceError") !== -1)
|
|
hasThrown = true;
|
|
}
|
|
assert(hasThrown);
|
|
}
|
|
noInline(shouldThrowTDZ);
|
|
|
|
function foo(a = function() { return c; }, b = a(), ...c) {
|
|
return a();
|
|
}
|
|
noInline(foo);
|
|
|
|
function baz(a = function() { return b; }, ...b) {
|
|
return a();
|
|
}
|
|
|
|
for (let i = 0; i < 1000; i++) {
|
|
shouldThrowTDZ(function() { foo(undefined, undefined, 10, 20); });
|
|
let o = {x: 20};
|
|
let result = baz(undefined, 10, o, "baz");
|
|
assert(result.length === 3);
|
|
assert(result[0] === 10);
|
|
assert(result[1] === o);
|
|
assert(result[2] === "baz");
|
|
}
|