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)
94 lines
1.6 KiB
JavaScript
94 lines
1.6 KiB
JavaScript
var testValue = 'test-value';
|
|
|
|
class A {
|
|
constructor() {
|
|
this.value = testValue;
|
|
}
|
|
}
|
|
|
|
class B extends A {
|
|
constructor(tdz) {
|
|
if (tdz)
|
|
this.id = 'id';
|
|
eval('super()');
|
|
}
|
|
}
|
|
|
|
var b = new B(false);
|
|
if (b.value !== testValue)
|
|
throw new Error("wrong value");
|
|
|
|
noInline(B);
|
|
|
|
let checkTDZ = function (klass, i) {
|
|
var exception;
|
|
try {
|
|
new klass(true);
|
|
} catch (e) {
|
|
exception = e;
|
|
if (!(e instanceof ReferenceError))
|
|
throw "Exception thrown in iteration " + i + " was not a reference error";
|
|
}
|
|
if (!exception)
|
|
throw "Exception not thrown for an unitialized this at iteration " + i;
|
|
}
|
|
|
|
for (var i = 0; i < 1e4; ++i) {
|
|
checkTDZ(B);
|
|
}
|
|
|
|
class C extends A {
|
|
constructor(tdz) {
|
|
if (tdz)
|
|
this.id = 'id';
|
|
eval("eval('super()')");
|
|
}
|
|
}
|
|
|
|
var c = new C(false);
|
|
if (c.value !== testValue)
|
|
throw new Error("wrong value");
|
|
|
|
for (var i = 0; i < 1e4; ++i) {
|
|
checkTDZ(C);
|
|
}
|
|
|
|
class D extends A {
|
|
constructor(tdz) {
|
|
if (tdz)
|
|
this.id = 'id';
|
|
eval("eval(\"eval('super()')\")");
|
|
}
|
|
}
|
|
|
|
var d = new D(false);
|
|
if (d.value !== testValue)
|
|
throw new Error("wrong value");
|
|
|
|
for (var i = 0; i < 1e4; ++i) {
|
|
checkTDZ(D);
|
|
}
|
|
|
|
var getEval = function (count) {
|
|
var newCount = count - 1;
|
|
return newCount === 0
|
|
? 'super()'
|
|
: 'eval(getEval(' + newCount + '))';
|
|
};
|
|
|
|
class E extends A {
|
|
constructor(tdz) {
|
|
if (tdz)
|
|
this.id = 'id';
|
|
eval(getEval(10));
|
|
}
|
|
}
|
|
|
|
var e = new E(false);
|
|
if (e.value !== testValue)
|
|
throw new Error("wrong value");
|
|
|
|
for (var i = 0; i < 1000; ++i) {
|
|
checkTDZ(E);
|
|
}
|