summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/regexp/atom-match-unicode-split-surrogate.js
blob: 3c1909fcf20f6e9e87d141f095c11270f47301a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function test(flags) {
  // RegExp with a simple atom matcher.
  // - Global flag to enable setting 'lastIndex'.
  let s = "\u{10000}";
  let re = RegExp(s, flags + "g");

  for (let i = 0; i < 200; ++i) {
    // Set lastIndex in the middle of the surrogate pair.
    re.lastIndex = 1;

    // |exec| will reset lastIndex to the start of the surrogate pair.
    let r = re.exec(s);

    // Atom match should succeed.
    assertEq(r[0], s);
    assertEq(r.index, 0);
    assertEq(re.lastIndex, 2);
  }
}

// Unicode flag to enable surrogate pairs support.
test("u");

// Unicode-Sets flag to enable surrogate pairs support.
test("v");