commit-queue@webkit.org | b2610c0 | 2015-12-08 20:24:04 +0000 | [diff] [blame] | 1 | var testCase = function (actual, expected, message) { |
| 2 | if (actual !== expected) { |
| 3 | throw message + ". Expected '" + expected + "', but was '" + actual + "'"; |
| 4 | } |
| 5 | }; |
| 6 | |
| 7 | var testValue = 'test-value'; |
| 8 | |
| 9 | var A = class A { |
| 10 | constructor() { |
| 11 | this.idValue = testValue; |
| 12 | } |
| 13 | }; |
| 14 | |
| 15 | var 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 | |
| 31 | for (var i = 0; i < 1000; i++) { |
| 32 | var b = new B(false); |
| 33 | } |
| 34 | |
| 35 | var 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 | |
| 50 | for (var i = 0; i < 1000; i++) { |
| 51 | testException(true, i); |
| 52 | } |