super-must-be-called.js (928B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 25.4.3 5 description: Super need to be called to initialize internals 6 info: | 7 25.4.3 The Promise Constructor 8 9 ... 10 11 The Promise constructor is designed to be subclassable. It may be used as the 12 value in an extends clause of a class definition. Subclass constructors that 13 intend to inherit the specified Promise behaviour must include a super call 14 to the Promise constructor to create and initialize the subclass instance with 15 the internal state necessary to support the Promise and Promise.prototype 16 built-in methods. 17 ---*/ 18 19 class Prom1 extends Promise { 20 constructor() {} 21 } 22 23 assert.throws(ReferenceError, function() { 24 new Prom1(); 25 }); 26 27 class Prom2 extends Promise { 28 constructor(exec) { 29 super(exec); 30 } 31 } 32 33 new Prom2(function() {}); 34 35 reportCompare(0, 0);