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

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

Issue 2788423003: [regexp] Updates for unicode escapes in capture names (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 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 9d6b9a95c7e0909e0cee0e27730e09c6be4d6520..855749bd346d59824803aaa5fe6dfd5b8b88e0e6 100644
--- a/test/mjsunit/harmony/regexp-named-captures.js
+++ b/test/mjsunit/harmony/regexp-named-captures.js
@@ -183,6 +183,23 @@ assertThrows("/\\1(?<=a)./u", SyntaxError);
assertThrows("/\\1(?<!a)./u", SyntaxError);
assertEquals(["a", "a"], /\1(?<a>.)/u.exec("abcd"));
+// Unicode escapes in capture names.
+assertTrue(/(?<a\uD801\uDCA4>.)/u.test("a")); // \u Lead \u Trail
+assertThrows("/(?<a\\uD801>.)/u", SyntaxError); // \u Lead
Yang 2017/04/05 08:03:35 Also test the case where you don't use the \u esca
jgruber 2017/04/07 08:01:23 You mean just a standard group name? "/(?<a\uD801>
jgruber 2017/04/07 08:02:54 Never mind, it's not. Will add a test.
+assertThrows("/(?<a\\uDCA4>.)/u", SyntaxError); // \u Trail
+assertTrue(/(?<\u0041>.)/u.test("a")); // \u NonSurrogate
+assertTrue(/(?<\u{0041}>.)/u.test("a")); // \u{ Non-surrogate }
+assertTrue(/(?<a\u{104A4}>.)/u.test("a")); // \u{ Surrogate, ID_Continue }
+assertThrows("/(?<a\\u{110000}>.)/u", SyntaxError); // \u{ Out-of-bounds }
+
+assertThrows("/(?<a\\uD801\uDCA4>.)/", SyntaxError);
+assertThrows("/(?<a\\uD801>.)/", SyntaxError);
+assertThrows("/(?<a\\uDCA4>.)/", SyntaxError);
+assertTrue(/(?<\u0041>.)/.test("a"));
+assertThrows("/(?<\\u{0041}>.)/", SyntaxError);
+assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError);
+assertThrows("/(?<a\\u{10FFFF}>.)/", SyntaxError);
+
// @@replace with a callable replacement argument (no named captures).
{
let result = "abcd".replace(/(.)(.)/u, (match, fst, snd, offset, str) => {
« 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