tor-browser

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

regular-subclassing.js (858B)


      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: 23.4.1
      5 description: Subclassing the WeakSet object
      6 info: |
      7  23.4.1 The WeakSet Constructor
      8 
      9  ...
     10 
     11  The WeakSet 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 WeakSet behaviour must include a super call to
     14  the WeakSet constructor to create and initialize the subclass instance with
     15  the internal state necessary to support the WeakSet.prototype built-in
     16  methods.
     17 features: [WeakSet]
     18 ---*/
     19 
     20 class WS extends WeakSet {}
     21 
     22 var set = new WS();
     23 var obj = {};
     24 
     25 assert.sameValue(set.has(obj), false);
     26 
     27 set.add(obj);
     28 assert.sameValue(set.has(obj), true);
     29 
     30 reportCompare(0, 0);