atom-match-unicode-split-surrogate.js (634B)
1 function test(flags) { 2 // RegExp with a simple atom matcher. 3 // - Global flag to enable setting 'lastIndex'. 4 let s = "\u{10000}"; 5 let re = RegExp(s, flags + "g"); 6 7 for (let i = 0; i < 200; ++i) { 8 // Set lastIndex in the middle of the surrogate pair. 9 re.lastIndex = 1; 10 11 // |exec| will reset lastIndex to the start of the surrogate pair. 12 let r = re.exec(s); 13 14 // Atom match should succeed. 15 assertEq(r[0], s); 16 assertEq(r.index, 0); 17 assertEq(re.lastIndex, 2); 18 } 19 } 20 21 // Unicode flag to enable surrogate pairs support. 22 test("u"); 23 24 // Unicode-Sets flag to enable surrogate pairs support. 25 test("v");