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)
93 lines
1.7 KiB
JavaScript
93 lines
1.7 KiB
JavaScript
function assert(b, m = "Bad!") {
|
|
if (!b) {
|
|
throw new Error(m);
|
|
}
|
|
}
|
|
|
|
function test(f, iters = 1000) {
|
|
for (let i = 0; i < iters; i++)
|
|
f();
|
|
}
|
|
|
|
function shouldThrowTDZ(f) {
|
|
let threw = false;
|
|
try {
|
|
f();
|
|
} catch(e) {
|
|
assert(e instanceof ReferenceError);
|
|
assert(e.toString() === "ReferenceError: Cannot access uninitialized variable.");
|
|
threw = true;
|
|
}
|
|
assert(threw);
|
|
}
|
|
|
|
test(function() {
|
|
class A {
|
|
get foo() {
|
|
return this._x;
|
|
}
|
|
set foo(x) {
|
|
this._x = x;
|
|
}
|
|
}
|
|
|
|
function fooProp() { return 'foo'; }
|
|
|
|
class B extends A {
|
|
constructor() {
|
|
super.foo = 20;
|
|
}
|
|
}
|
|
|
|
class C extends A {
|
|
constructor() {
|
|
super[fooProp()] = 20;
|
|
}
|
|
}
|
|
|
|
class D extends A {
|
|
constructor() {
|
|
super[fooProp()];
|
|
}
|
|
}
|
|
|
|
class E extends A {
|
|
constructor() {
|
|
super.foo;
|
|
}
|
|
}
|
|
|
|
class F extends A {
|
|
constructor() {
|
|
(() => super.foo = 20)();
|
|
}
|
|
}
|
|
|
|
class G extends A {
|
|
constructor() {
|
|
(() => super[fooProp()] = 20)();
|
|
}
|
|
}
|
|
|
|
class H extends A {
|
|
constructor() {
|
|
(() => super[fooProp()])();
|
|
}
|
|
}
|
|
|
|
class I extends A {
|
|
constructor() {
|
|
(() => super.foo)();
|
|
}
|
|
}
|
|
|
|
shouldThrowTDZ(function() { new B; });
|
|
shouldThrowTDZ(function() { new C; });
|
|
shouldThrowTDZ(function() { new D; });
|
|
shouldThrowTDZ(function() { new E; });
|
|
shouldThrowTDZ(function() { new F; });
|
|
shouldThrowTDZ(function() { new G; });
|
|
shouldThrowTDZ(function() { new H; });
|
|
shouldThrowTDZ(function() { new I; });
|
|
});
|