super-must-be-called.js (949B)
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: 24.2.2 5 description: Super need to be called to initialize internals 6 info: | 7 24.2.2 The DataView Constructor 8 9 ... 10 11 The DataView constructor is designed to be subclassable. It may be used as the 12 value of an extends clause of a class definition. Subclass constructors that 13 intend to inherit the specified DataView behaviour must include a super call 14 to the DataView constructor to create and initialize subclass instances with 15 the internal state necessary to support the DataView.prototype built-in 16 methods. 17 ---*/ 18 19 class DV1 extends DataView { 20 constructor() {} 21 } 22 23 var buffer = new ArrayBuffer(1); 24 25 assert.throws(ReferenceError, function() { 26 new DV1(buffer); 27 }); 28 29 class DV2 extends DataView { 30 constructor(length) { 31 super(length); 32 } 33 } 34 35 new DV2(buffer); 36 37 reportCompare(0, 0);