| description('Tests for calling the constructors of ES6 classes'); |
| class A { constructor() {} }; |
| class B extends A { constructor() { super() } }; |
| function shouldThrow(s, message) { |
| if (e.toString() === eval(message)) |
| testPassed(s + ":::" + message); |
| testFailed(e.toString() + ":::" + message); |
| function shouldNotThrow(s) { |
| shouldThrow('A()', '"TypeError: Cannot call a class constructor"'); |
| shouldThrow('B()', '"TypeError: Cannot call a class constructor"'); |
| shouldNotThrow('new (class { constructor() {} })()'); |
| shouldThrow('(class { constructor() {} })()', '"TypeError: Cannot call a class constructor"'); |
| shouldThrow('new (class extends null { constructor() { super() } })()', '"TypeError: function is not a constructor (evaluating \'super()\')"'); |
| shouldThrow('(class extends null { constructor() { super() } })()', '"TypeError: Cannot call a class constructor"'); |
| var successfullyParsed = true; |