tor-browser

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

regular-subclassing.js (753B)


      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: 21.2.3
      5 description: Subclassing the RegExp object
      6 info: |
      7  21.2.3 The RegExp Constructor
      8 
      9  ...
     10 
     11  The RegExp 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 RegExp behaviour must include a super call to
     14  the RegExp constructor to create and initialize subclass instances with the
     15  necessary internal slots.
     16 ---*/
     17 
     18 class RE extends RegExp {}
     19 
     20 var re = new RE(39);
     21 
     22 assert.sameValue(re.test('TC39'), true);
     23 assert.sameValue(re.test('42'), false);
     24 
     25 reportCompare(0, 0);