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

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

Issue 2630233003: [regexp] Create property on result for each named capture (Closed)
Patch Set: Remove unused CaptureNameMapOffset Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« src/regexp/regexp-parser.cc ('K') | « src/regexp/regexp-parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/regexp-named-captures.js
diff --git a/test/mjsunit/harmony/regexp-named-captures.js b/test/mjsunit/harmony/regexp-named-captures.js
index ced8e4b2f6ba330698f43bbcad1a5a7afc72c82c..53f4e0e7c9c23584500e362f8d32175072a36852 100644
--- a/test/mjsunit/harmony/regexp-named-captures.js
+++ b/test/mjsunit/harmony/regexp-named-captures.js
@@ -74,3 +74,31 @@ assertEquals(["bab", "b"], "bab".match(/(?<a>\k<a>\w)../u));
// Reference before group.
assertEquals(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/u));
assertEquals(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u));
+
+// Reference properties.
+assertEquals("a", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").a);
+assertEquals("b", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").b);
+assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>/u.exec("aba").c);
+assertFalse(/(?<a>a)(?<b>b)\k<a>/u.exec("aba").hasOwnProperty("c"));
+assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").c);
+assertTrue(/(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").hasOwnProperty("c"));
+
+// Unicode names.
+assertEquals("a", /(?<π>a)/u.exec("bab").π);
+assertEquals("a", /(?<\u{03C0}>a)/u.exec("bab").\u03C0);
+assertEquals("a", /(?<$>a)/u.exec("bab").$);
+assertEquals("a", /(?<_>a)/u.exec("bab")._);
+assertEquals("a", /(?<$𐒤>a)/u.exec("bab").$𐒤);
+assertEquals("a", /(?<_\u200C>a)/u.exec("bab")._\u200C);
+assertEquals("a", /(?<_\u200D>a)/u.exec("bab")._\u200D);
+assertEquals("a", /(?<ಠ_ಠ>a)/u.exec("bab").ಠ_ಠ);
+assertThrows('/(?<❤>a)/u');
+assertThrows('/(?<𐒤>a)/u'); // ID_Continue but not ID_Start.
Dan Ehrenberg 2017/01/18 18:19:04 For syntax error tests, how about assertThrows('/(
jgruber 2017/01/19 15:59:12 Done.
+
+// Capture name conflicts.
+assertThrows(() => /(?<index>a)/u);
+assertThrows(() => /(?<input>a)/u);
+assertThrows(() => /(?<length>a)/u);
+
+assertEquals("a", /(?<inde>a)/u.exec("a").inde);
+assertEquals("a", /(?<indexi>a)/u.exec("a").indexi);
« src/regexp/regexp-parser.cc ('K') | « src/regexp/regexp-parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698