OLD | NEW |
| (Empty) |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --harmony-unicode-regexps --harmony-regexp-lookbehind | |
6 | |
7 var r = /./ug; | |
8 assertEquals(["\ud800\udc00"], r.exec("\ud800\udc00\ud801\udc01")); | |
9 assertEquals(2, r.lastIndex); | |
10 r.lastIndex = 1; | |
11 assertEquals(["\ud800\udc00"], r.exec("\ud800\udc00\ud801\udc01")); | |
12 assertEquals(2, r.lastIndex); | |
13 assertEquals(["\ud801\udc01"], r.exec("\ud800\udc00\ud801\udc01")); | |
14 r.lastIndex = 3; | |
15 assertEquals(["\ud801\udc01"], r.exec("\ud800\udc00\ud801\udc01")); | |
16 assertEquals(4, r.lastIndex); | |
17 r.lastIndex = 4; | |
18 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
19 assertEquals(0, r.lastIndex); | |
20 r.lastIndex = 5; | |
21 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
22 assertEquals(0, r.lastIndex); | |
23 | |
24 r.lastIndex = 3; | |
25 assertEquals(["\ud802"], r.exec("\ud800\udc00\ud801\ud802")); | |
26 r.lastIndex = 4; | |
27 assertNull(r.exec("\ud800\udc00\ud801\ud802")); | |
28 | |
29 r = /./g; | |
30 assertEquals(["\ud800"], r.exec("\ud800\udc00\ud801\udc01")); | |
31 assertEquals(1, r.lastIndex); | |
32 assertEquals(["\udc00"], r.exec("\ud800\udc00\ud801\udc01")); | |
33 assertEquals(2, r.lastIndex); | |
34 assertEquals(["\ud801"], r.exec("\ud800\udc00\ud801\udc01")); | |
35 assertEquals(3, r.lastIndex); | |
36 assertEquals(["\udc01"], r.exec("\ud800\udc00\ud801\udc01")); | |
37 assertEquals(4, r.lastIndex); | |
38 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
39 assertEquals(0, r.lastIndex); | |
40 r.lastIndex = 1; | |
41 assertEquals(["\udc00"], r.exec("\ud800\udc00\ud801\udc01")); | |
42 assertEquals(2, r.lastIndex); | |
43 | |
44 // ------------------------ | |
45 | |
46 r = /^./ug; | |
47 assertEquals(["\ud800\udc00"], r.exec("\ud800\udc00\ud801\udc01")); | |
48 assertEquals(2, r.lastIndex); | |
49 r.lastIndex = 1; | |
50 assertEquals(["\ud800\udc00"], r.exec("\ud800\udc00\ud801\udc01")); | |
51 assertEquals(2, r.lastIndex); | |
52 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
53 assertEquals(0, r.lastIndex); | |
54 r.lastIndex = 3; | |
55 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
56 assertEquals(0, r.lastIndex); | |
57 r.lastIndex = 4; | |
58 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
59 assertEquals(0, r.lastIndex); | |
60 r.lastIndex = 5; | |
61 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
62 assertEquals(0, r.lastIndex); | |
63 | |
64 r = /^./g; | |
65 assertEquals(["\ud800"], r.exec("\ud800\udc00\ud801\udc01")); | |
66 assertEquals(1, r.lastIndex); | |
67 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
68 assertEquals(0, r.lastIndex); | |
69 r.lastIndex = 3; | |
70 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
71 assertEquals(0, r.lastIndex); | |
72 | |
73 //------------------------ | |
74 | |
75 r = /(?:(^.)|.)/ug; | |
76 assertEquals(["\ud800\udc00", "\ud800\udc00"], | |
77 r.exec("\ud800\udc00\ud801\udc01")); | |
78 assertEquals(2, r.lastIndex); | |
79 r.lastIndex = 1; | |
80 assertEquals(["\ud800\udc00", "\ud800\udc00"], | |
81 r.exec("\ud800\udc00\ud801\udc01")); | |
82 assertEquals(2, r.lastIndex); | |
83 assertEquals(["\ud801\udc01", undefined], r.exec("\ud800\udc00\ud801\udc01")); | |
84 r.lastIndex = 3; | |
85 assertEquals(["\ud801\udc01", undefined], r.exec("\ud800\udc00\ud801\udc01")); | |
86 r.lastIndex = 4; | |
87 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
88 r.lastIndex = 5; | |
89 assertNull(r.exec("\ud800\udc00\ud801\udc01")); | |
90 | |
91 r.lastIndex = 3; | |
92 assertEquals(["\ud802", undefined], r.exec("\ud800\udc00\ud801\ud802")); | |
93 r.lastIndex = 4; | |
94 assertNull(r.exec("\ud800\udc00\ud801\ud802")); | |
95 | |
96 r = /(?:(^.)|.)/g; | |
97 assertEquals(["\ud800", "\ud800"], | |
98 r.exec("\ud800\udc00\ud801\udc01")); | |
99 assertEquals(1, r.lastIndex); | |
100 assertEquals(["\udc00", undefined], r.exec("\ud800\udc00\ud801\udc01")); | |
101 assertEquals(2, r.lastIndex); | |
102 r.lastIndex = 3; | |
103 assertEquals(["\udc01", undefined], r.exec("\ud800\udc00\ud801\udc01")); | |
104 assertEquals(4, r.lastIndex); | |
OLD | NEW |