test262/implementation-contributed/javascriptcore/stress/rest-parameter-and-default-arguments.js
test262-automation e9a5a7f918 [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) (#1620)
* [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)
2018-07-03 15:59:58 -04:00

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");
}