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

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

Issue 2791163003: [regexp] Support unicode capture names in non-unicode patterns (Closed)
Patch Set: Remove template parameter from ReadNext Created 3 years, 8 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 assertThrows("/(?<$𐒤>a)/", SyntaxError); 150 assertEquals("a", /(?<$𐒤>a)/.exec("bab").groups.$𐒤);
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // named captures). 366 // named captures).
367 { 367 {
368 let re = toSlowMode(/(?<fst>.)(?<snd>.)/u); 368 let re = toSlowMode(/(?<fst>.)(?<snd>.)/u);
369 assertEquals("bacd", "abcd".replace(re, "$<snd>$<fst>")); 369 assertEquals("bacd", "abcd".replace(re, "$<snd>$<fst>"));
370 assertEquals("bacd", "abcd".replace(re, "$2$1")); 370 assertEquals("bacd", "abcd".replace(re, "$2$1"));
371 assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError); 371 assertThrows(() => "abcd".replace(re, "$<snd"), SyntaxError);
372 assertEquals("cd", "abcd".replace(re, "$<42$1>")); 372 assertEquals("cd", "abcd".replace(re, "$<42$1>"));
373 assertEquals("cd", "abcd".replace(re, "$<thd>")); 373 assertEquals("cd", "abcd".replace(re, "$<thd>"));
374 assertEquals("cd", "abcd".replace(re, "$<$1>")); 374 assertEquals("cd", "abcd".replace(re, "$<$1>"));
375 } 375 }
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