tor-browser

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

back-references.js (2285B)


      1 // Copyright (C) 2017 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-assertion
      6 description: Back references
      7 info: |
      8  The production Assertion :: (?<=Disjunction) evaluates as follows:
      9    1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m.
     10    2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation
     11        c, and performs the following steps:
     12      a. Let d be a Continuation that always returns its State argument as a successful MatchResult.
     13      b. Call m(x, d) and let r be its result.
     14      c. If r is failure, return failure.
     15      d. Let y be r's State.
     16      e. Let cap be y's captures List.
     17      f. Let xe be x's endIndex.
     18      g. Let z be the State (xe, cap).
     19      h. Call c(z) and return its result.
     20 features: [regexp-lookbehind]
     21 includes: [compareArray.js]
     22 ---*/
     23 
     24 assert.compareArray("abb".match(/(.)(?<=(\1\1))/), ["b", "b", "bb"], "#1");
     25 assert.compareArray("abB".match(/(.)(?<=(\1\1))/i), ["B", "B", "bB"], "#2");
     26 assert.compareArray("aabAaBa".match(/((\w)\w)(?<=\1\2\1)/i), ["aB", "aB", "a"], "#3");
     27 assert.compareArray("aabAaBa".match(/(\w(\w))(?<=\1\2\1)/i), ["Ba", "Ba", "a"], "#4");
     28 assert.compareArray("abaBbAa".match(/(?=(\w))(?<=(\1))./i), ["b", "b", "B"], "#5");
     29 assert.compareArray("  'foo'  ".match(/(?<=(.))(\w+)(?=\1)/), ["foo", "'", "foo"], "#6");
     30 assert.compareArray("  \"foo\"  ".match(/(?<=(.))(\w+)(?=\1)/), ["foo", "\"", "foo"], "#7");
     31 assert.compareArray("abbb".match(/(.)(?<=\1\1\1)/), ["b", "b"], "#8");
     32 assert.compareArray("fababab".match(/(..)(?<=\1\1\1)/), ["ab", "ab"], "#9");
     33 
     34 assert.sameValue("  .foo\"  ".match(/(?<=(.))(\w+)(?=\1)/), null, "#10");
     35 assert.sameValue("ab".match(/(.)(?<=\1\1\1)/), null, "#11");
     36 assert.sameValue("abb".match(/(.)(?<=\1\1\1)/), null, "#12");
     37 assert.sameValue("ab".match(/(..)(?<=\1\1\1)/), null, "#13");
     38 assert.sameValue("abb".match(/(..)(?<=\1\1\1)/), null, "#14");
     39 assert.sameValue("aabb".match(/(..)(?<=\1\1\1)/), null, "#15");
     40 assert.sameValue("abab".match(/(..)(?<=\1\1\1)/), null, "#16");
     41 assert.sameValue("fabxbab".match(/(..)(?<=\1\1\1)/), null, "#17");
     42 assert.sameValue("faxabab".match(/(..)(?<=\1\1\1)/), null, "#18");
     43 
     44 
     45 reportCompare(0, 0);