test262/implementation-contributed/javascriptcore/stress/super-property-access-to-this.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

49 lines
1.0 KiB
JavaScript

"use strict";
function assert(b) {
if (!b)
throw new Error("Bad assertion")
}
function test(f, n = 1000) {
for (let i = 0; i < n; ++i)
f();
}
class Base {
get foo() { return this; }
}
class Child extends Base {
a() {
return super.foo;
}
b() {
let arr = () => super.foo;
return arr();
}
};
let A = Child.prototype.a;
var AA = Child.prototype.a;
this.AAA = Child.prototype.a;
let globalObj = this;
test(function() {
assert(Child.prototype.a.call("xyz") === "xyz");
let obj = {};
assert(Child.prototype.a.call(obj) === obj);
assert(Child.prototype.a.call(25) === 25);
assert(Child.prototype.a.call(globalObj) === globalObj);
assert(Child.prototype.b.call("xyz") === "xyz");
assert(Child.prototype.b.call(obj) === obj);
assert(Child.prototype.b.call(25) === 25);
assert(Child.prototype.b.call(globalObj) === globalObj);
assert(A() === undefined);
assert(AA() === undefined);
assert(AAA() === undefined);
});