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)
38 lines
999 B
JavaScript
38 lines
999 B
JavaScript
F = class extends Function { }
|
|
N = class extends null { }
|
|
|
|
function test(i) {
|
|
|
|
let f = new F("x", "return x + " + i + ";");
|
|
let C = new F("x", "this.x = x; this.i = " + i);
|
|
|
|
if (!(f instanceof Function && f instanceof F))
|
|
throw "bad chain";
|
|
|
|
if (f(1) !== i+1)
|
|
throw "function was not called correctly";
|
|
|
|
let o = new C("hello");
|
|
if (o.x !== "hello" || o.i !== i)
|
|
throw "function as constructor was not correct";
|
|
|
|
let g = new F("x", "y", "return this.foo + x + y");
|
|
if (g.call({foo:1}, 1, 1) !== 3)
|
|
throw "function was not .callable";
|
|
|
|
let g2 = g.bind({foo:1}, 1);
|
|
if (!(g2 instanceof F))
|
|
throw "the binding of a subclass should inherit from the bound function's class";
|
|
|
|
if (g2(1) !== 3)
|
|
throw "binding didn't work";
|
|
|
|
let bound = C.bind(null)
|
|
if (bound.__proto__ !== C.__proto__)
|
|
throw "binding with null as prototype didn't work";
|
|
}
|
|
noInline(test);
|
|
|
|
for (i = 0; i < 10000; i++)
|
|
test(i);
|