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)
47 lines
909 B
JavaScript
47 lines
909 B
JavaScript
function assert(b, m="") {
|
|
if (!b)
|
|
throw new Error("Bad assertion: " + m);
|
|
}
|
|
noInline(assert);
|
|
|
|
let called = false;
|
|
function baz(c) {
|
|
if (c) {
|
|
Array.prototype[Symbol.iterator] = function() {
|
|
assert(false, "should not be called!");
|
|
let i = 0;
|
|
return {
|
|
next() {
|
|
assert(false, "should not be called!");
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
noInline(baz);
|
|
|
|
function bar(...args) {
|
|
return args;
|
|
}
|
|
noInline(bar);
|
|
|
|
function foo(c, ...args) {
|
|
args = [...args];
|
|
baz(c);
|
|
return bar.apply(null, args);
|
|
}
|
|
noInline(foo);
|
|
|
|
function test(c) {
|
|
const args = [{}, 20, [], 45];
|
|
let r = foo(c, ...args);
|
|
assert(r.length === r.length);
|
|
for (let i = 0; i < r.length; i++)
|
|
assert(r[i] === args[i]);
|
|
}
|
|
noInline(test);
|
|
for (let i = 0; i < 40000; i++) {
|
|
test(false);
|
|
}
|
|
test(true);
|