tor-browser

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

non-empty-class-ranges-no-dash.js (1657B)


      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 esid: sec-regular-expressions-patterns
      5 es6id: B.1.4
      6 description: Extensions to NonemptyClassRangesNoDash production
      7 info: |
      8    The production
      9    NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates
     10    as follows:
     11 
     12    1. Evaluate ClassAtomNoDash to obtain a CharSet A.
     13    2. Evaluate ClassAtom to obtain a CharSet B.
     14    3. Evaluate ClassRanges to obtain a CharSet C.
     15    4. Call CharacterRangeOrUnion(A, B) and let D be the resulting CharSet.
     16    5. Return the union of CharSets D and C.
     17 
     18    B.1.4.1.1 Runtime Semantics: CharacterRangeOrUnion Abstract Operation
     19 
     20    1. If Unicode is false, then
     21       a. If A does not contain exactly one character or B does not contain
     22          exactly one character, then
     23          i. Let C be the CharSet containing the single character - U+002D
     24             (HYPHEN-MINUS).
     25          ii. Return the union of CharSets A, B and C.
     26    2. Return CharacterRange(A, B).
     27 ---*/
     28 
     29 var match;
     30 
     31 match = /[\d-a]+/.exec(':a0123456789-:');
     32 assert.sameValue(match[0], 'a0123456789-');
     33 
     34 match = /[\d-az]+/.exec(':a0123456789z-:');
     35 assert.sameValue(match[0], 'a0123456789z-');
     36 
     37 match = /[%-\d]+/.exec('&%0123456789-&');
     38 assert.sameValue(match[0], '%0123456789-');
     39 
     40 match = /[%-\dz]+/.exec('&%0123456789z-&');
     41 assert.sameValue(match[0], '%0123456789z-');
     42 
     43 match = /[\s-\d]+/.exec('& \t0123456789-&');
     44 assert.sameValue(match[0], ' \t0123456789-');
     45 
     46 match = /[\s-\dz]+/.exec('& \t0123456789z-&');
     47 assert.sameValue(match[0], ' \t0123456789z-');
     48 
     49 reportCompare(0, 0);