blob: 6fbb6d5acb74bde68d5dd6937c11da6c3106c6f5 [file] [log] [blame]
commit-queue@webkit.orgb2610c02015-12-08 20:24:04 +00001var testCase = function (actual, expected, message) {
2 if (actual !== expected) {
3 throw message + ". Expected '" + expected + "', but was '" + actual + "'";
4 }
5};
6
7var testValue = 'test-value';
8
9var A = class A {
10 constructor() {
11 this.idValue = testValue;
12 }
13};
14
15var B = class B extends A {
16 constructor (beforeSuper) {
17 var arrow = () => eval('(() => this.idValue)()');
18
19 if (beforeSuper) {
20 var result = arrow();
21 super();
22 testCase(result, testValue, "Error: has to be TDZ error");
23 } else {
24 super();
25 let result= arrow();
26 testCase(result, testValue, "Error: super() should create this and put value into idValue property");
27 }
28 }
29};
30
31for (var i = 0; i < 1000; i++) {
32 var b = new B(false);
33}
34
35var testException = function (value, index) {
36 var exception;
37 try {
38 new B(value);
39 } catch (e) {
40 exception = e;
41 if (!(e instanceof ReferenceError))
42 throw "Exception thrown was not a reference error";
43 }
44
45 if (!exception)
46 throw "Exception not thrown for an unitialized this at iteration #" + index;
47}
48
49
50for (var i = 0; i < 1000; i++) {
51 testException(true, i);
52}