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