tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

super-must-be-called.js (933B)


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