Commit 9372dd95 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Fix unicode escapes in test strings

Some of these tests pass the pattern as a string, and in this case
there's a subtle distinction between

"/\u{0041}/"  // Unicode escape interpreted in string literal.

and

"/\\u{0041}/"  // Unicode escape interpreted by regexp parser.

Extend these tests to check both cases.

Thanks littledan@ for pointing this out.

BUG=v8:5437

Review-Url: https://codereview.chromium.org/2839923002
Cr-Commit-Position: refs/heads/master@{#44840}
parent dde47c04
......@@ -195,10 +195,15 @@ 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>.)/u", SyntaxError); // Lead
assertThrows("/(?<a\\uDCA4>.)/u", SyntaxError); // Trail
assertThrows("/(?<a\uD801>.)/u", SyntaxError); // Lead
assertThrows("/(?<a\uDCA4>.)/u", SyntaxError); // Trail
assertTrue(RegExp("(?<\\u{0041}>.)", "u").test("a")); // Non-surrogate
assertTrue(RegExp("(?<a\\u{104A4}>.)", "u").test("a")); // Surrogate,ID_Continue
assertTrue(RegExp("(?<\u{0041}>.)", "u").test("a")); // Non-surrogate
assertTrue(RegExp("(?<a\u{104A4}>.)", "u").test("a")); // Surrogate,ID_Continue
assertTrue(RegExp("(?<\\u0041>.)", "u").test("a")); // Non-surrogate
assertThrows("/(?<a\\uD801\uDCA4>.)/", SyntaxError);
assertThrows("/(?<a\\uD801>.)/", SyntaxError);
......@@ -207,10 +212,15 @@ assertTrue(/(?<\u0041>.)/.test("a"));
assertThrows("/(?<\\u{0041}>.)/", SyntaxError);
assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError);
assertThrows("/(?<a\\u{10FFFF}>.)/", SyntaxError);
assertThrows("/(?<a\\uD801>.)/", SyntaxError); // Lead
assertThrows("/(?<a\\uDCA4>.)/", SyntaxError); // Trail;
assertThrows("/(?<a\uD801>.)/", SyntaxError); // Lead
assertThrows("/(?<a\uDCA4>.)/", SyntaxError); // Trail
assertThrows("/(?<\\u{0041}>.)/", SyntaxError); // Non-surrogate
assertThrows("/(?<a\\u{104A4}>.)/", SyntaxError); // Surrogate, ID_Continue
assertTrue(RegExp("(?<\u{0041}>.)").test("a")); // Non-surrogate
assertTrue(RegExp("(?<a\u{104A4}>.)").test("a")); // Surrogate, ID_Continue
assertTrue(RegExp("(?<\\u0041>.)").test("a")); // Non-surrogate
// @@replace with a callable replacement argument (no named captures).
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment