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)
178 lines
2.8 KiB
JavaScript
178 lines
2.8 KiB
JavaScript
var testCase = function (actual, expected, message) {
|
|
if (actual !== expected) {
|
|
throw message + ". Expected '" + expected + "', but was '" + actual + "'";
|
|
}
|
|
};
|
|
|
|
var A = class A {
|
|
constructor() {
|
|
this.id = 'A'
|
|
}
|
|
};
|
|
|
|
var B = class B extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this.id === 'A') {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var C = class C extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this > 5) {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var D = class D extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this < 5) {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var E = class E extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this !== 5) {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var F = class F extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this <= 5) {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var G = class G extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this >= 5) {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var G = class G extends A {
|
|
constructor(beforeSuper) {
|
|
var f = () => {
|
|
if (this === 5) {
|
|
return 'ok';
|
|
}
|
|
return 'ok';
|
|
};
|
|
let val;
|
|
if (beforeSuper) {
|
|
val = f();
|
|
super();
|
|
} else {
|
|
super();
|
|
val = f();
|
|
}
|
|
this.res = val;
|
|
}
|
|
};
|
|
|
|
var tryToCreate = function (classForCreate) {
|
|
var result = false;
|
|
try {
|
|
new classForCreate(true);
|
|
} catch (e) {
|
|
result = e instanceof ReferenceError;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
var check = function (classForCheck) {
|
|
testCase(tryToCreate(classForCheck), true, 'Exception wasn\'t thrown or was not a reference error');
|
|
var result = new classForCheck(false);
|
|
testCase(result.res, 'ok', 'Error in setting id ');
|
|
}
|
|
|
|
for (var i = 0; i < 10000; i++) {
|
|
check(B);
|
|
check(C);
|
|
check(D);
|
|
check(E);
|
|
check(F);
|
|
check(G);
|
|
}
|