Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/mjsunit/harmony/regexp-named-captures.js

Issue 2859933003: Revert of [regexp] Support unicode capture names in non-unicode patterns (Closed)
Patch Set: Fixing test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-regexp-named-captures --harmony-regexp-lookbehind 5 // Flags: --harmony-regexp-named-captures --harmony-regexp-lookbehind
6 6
7 // Malformed named captures. 7 // Malformed named captures.
8 assertThrows("/(?<>a)/u", SyntaxError); // Empty name. 8 assertThrows("/(?<>a)/u", SyntaxError); // Empty name.
9 assertThrows("/(?<aa)/u", SyntaxError); // Unterminated name. 9 assertThrows("/(?<aa)/u", SyntaxError); // Unterminated name.
10 assertThrows("/(?<42a>a)/u", SyntaxError); // Name starting with digits. 10 assertThrows("/(?<42a>a)/u", SyntaxError); // Name starting with digits.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 assertEquals("a", /(?<$𐒤>a)/u.exec("bab").groups.$𐒤); 140 assertEquals("a", /(?<$𐒤>a)/u.exec("bab").groups.$𐒤);
141 assertEquals("a", /(?<_\u200C>a)/u.exec("bab").groups._\u200C); 141 assertEquals("a", /(?<_\u200C>a)/u.exec("bab").groups._\u200C);
142 assertEquals("a", /(?<_\u200D>a)/u.exec("bab").groups._\u200D); 142 assertEquals("a", /(?<_\u200D>a)/u.exec("bab").groups._\u200D);
143 assertEquals("a", /(?<ಠ_ಠ>a)/u.exec("bab").groups.ಠ_ಠ); 143 assertEquals("a", /(?<ಠ_ಠ>a)/u.exec("bab").groups.ಠ_ಠ);
144 assertThrows('/(?<❤>a)/u', SyntaxError); 144 assertThrows('/(?<❤>a)/u', SyntaxError);
145 assertThrows('/(?<𐒤>a)/u', SyntaxError); // ID_Continue but not ID_Start. 145 assertThrows('/(?<𐒤>a)/u', SyntaxError); // ID_Continue but not ID_Start.
146 146
147 assertEquals("a", /(?<π>a)/.exec("bab").groups.π); 147 assertEquals("a", /(?<π>a)/.exec("bab").groups.π);
148 assertEquals("a", /(?<$>a)/.exec("bab").groups.$); 148 assertEquals("a", /(?<$>a)/.exec("bab").groups.$);
149 assertEquals("a", /(?<_>a)/.exec("bab").groups._); 149 assertEquals("a", /(?<_>a)/.exec("bab").groups._);
150 assertEquals("a", /(?<$𐒤>a)/.exec("bab").groups.$𐒤); 150 assertThrows("/(?<$𐒤>a)/", SyntaxError);
151 assertEquals("a", /(?<ಠ_ಠ>a)/.exec("bab").groups.ಠ_ಠ); 151 assertEquals("a", /(?<ಠ_ಠ>a)/.exec("bab").groups.ಠ_ಠ);
152 assertThrows('/(?<❤>a)/', SyntaxError); 152 assertThrows('/(?<❤>a)/', SyntaxError);
153 assertThrows('/(?<𐒤>a)/', SyntaxError); // ID_Continue but not ID_Start. 153 assertThrows('/(?<𐒤>a)/', SyntaxError); // ID_Continue but not ID_Start.
154 154
155 // Interaction with lookbehind assertions. 155 // Interaction with lookbehind assertions.
156 assertEquals(["f", "c"], "abcdef".match(/(?<=(?<a>\w){3})f/u)); 156 assertEquals(["f", "c"], "abcdef".match(/(?<=(?<a>\w){3})f/u));
157 assertEquals({a: "c"}, "abcdef".match(/(?<=(?<a>\w){3})f/u).groups); 157 assertEquals({a: "c"}, "abcdef".match(/(?<=(?<a>\w){3})f/u).groups);
158 assertEquals({a: "b"}, "abcdef".match(/(?<=(?<a>\w){4})f/u).groups); 158 assertEquals({a: "b"}, "abcdef".match(/(?<=(?<a>\w){4})f/u).groups);
159 assertEquals({a: "a"}, "abcdef".match(/(?<=(?<a>\w)+)f/u).groups); 159 assertEquals({a: "a"}, "abcdef".match(/(?<=(?<a>\w)+)f/u).groups);
160 assertNull("abcdef".match(/(?<=(?<a>\w){6})f/u)); 160 assertNull("abcdef".match(/(?<=(?<a>\w){6})f/u));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 assertThrows("/(?<\\u{0041}>.)/", SyntaxError); 212 assertThrows("/(?<\\u{0041}>.)/", SyntaxError);
213 assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError); 213 assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError);
214 assertThrows("/(?<a\\u{10FFFF}>.)/", SyntaxError); 214 assertThrows("/(?<a\\u{10FFFF}>.)/", SyntaxError);
215 assertThrows("/(?<a\\uD801>.)/", SyntaxError); // Lead 215 assertThrows("/(?<a\\uD801>.)/", SyntaxError); // Lead
216 assertThrows("/(?<a\\uDCA4>.)/", SyntaxError); // Trail; 216 assertThrows("/(?<a\\uDCA4>.)/", SyntaxError); // Trail;
217 assertThrows("/(?<a\uD801>.)/", SyntaxError); // Lead 217 assertThrows("/(?<a\uD801>.)/", SyntaxError); // Lead
218 assertThrows("/(?<a\uDCA4>.)/", SyntaxError); // Trail 218 assertThrows("/(?<a\uDCA4>.)/", SyntaxError); // Trail
219 assertThrows("/(?<\\u{0041}>.)/", SyntaxError); // Non-surrogate 219 assertThrows("/(?<\\u{0041}>.)/", SyntaxError); // Non-surrogate
220 assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError); // Surrogate, ID_Continue 220 assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError); // Surrogate, ID_Continue
221 assertTrue(RegExp("(?<\u{0041}>.)").test("a")); // Non-surrogate 221 assertTrue(RegExp("(?<\u{0041}>.)").test("a")); // Non-surrogate
222 assertTrue(RegExp("(?<a\u{104A4}>.)").test("a")); // Surrogate, ID_Continue 222 assertThrows("(?<a\u{104A4}>.)", SyntaxError); // Surrogate, ID_Continue
223 assertTrue(RegExp("(?<\\u0041>.)").test("a")); // Non-surrogate 223 assertTrue(RegExp("(?<\\u0041>.)").test("a")); // Non-surrogate
224 224
225 // @@replace with a callable replacement argument (no named captures). 225 // @@replace with a callable replacement argument (no named captures).
226 { 226 {
227 let result = "abcd".replace(/(.)(.)/u, (match, fst, snd, offset, str) => { 227 let result = "abcd".replace(/(.)(.)/u, (match, fst, snd, offset, str) => {
228 assertEquals("ab", match); 228 assertEquals("ab", match);
229 assertEquals("a", fst); 229 assertEquals("a", fst);
230 assertEquals("b", snd); 230 assertEquals("b", snd);
231 assertEquals(0, offset); 231 assertEquals(0, offset);
232 assertEquals("abcd", str); 232 assertEquals("abcd", str);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 { 406 {
407 let re = toSlowMode(/(?<fst>.)(?<snd>.)|(?<thd>x)/u); 407 let re = toSlowMode(/(?<fst>.)(?<snd>.)|(?<thd>x)/u);
408 assertEquals("bacd", "abcd".replace(re, "$<snd>$<fst>")); 408 assertEquals("bacd", "abcd".replace(re, "$<snd>$<fst>"));
409 assertEquals("bacd", "abcd".replace(re, "$2$1")); 409 assertEquals("bacd", "abcd".replace(re, "$2$1"));
410 assertEquals("cd", "abcd".replace(re, "$<thd>")); 410 assertEquals("cd", "abcd".replace(re, "$<thd>"));
411 assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError); 411 assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError);
412 assertThrows(() => "abcd".replace(re, "$<42$1>"), SyntaxError); 412 assertThrows(() => "abcd".replace(re, "$<42$1>"), SyntaxError);
413 assertThrows(() => "abcd".replace(re, "$<fth>"), SyntaxError); 413 assertThrows(() => "abcd".replace(re, "$<fth>"), SyntaxError);
414 assertThrows(() => "abcd".replace(re, "$<$1>"), SyntaxError); 414 assertThrows(() => "abcd".replace(re, "$<$1>"), SyntaxError);
415 } 415 }
OLDNEW
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698