diff --git a/test/built-ins/RegExp/named-groups/unicode-property-names.js b/test/built-ins/RegExp/named-groups/unicode-property-names.js index c12df27828..27bf125746 100644 --- a/test/built-ins/RegExp/named-groups/unicode-property-names.js +++ b/test/built-ins/RegExp/named-groups/unicode-property-names.js @@ -23,6 +23,8 @@ assert(/(?.)/u.test("a"), "\\u Lead \\u Trail"); assert(/(?<\u0041>.)/u.test("a"), "\\u NonSurrogate"); assert(/(?<\u{0041}>.)/u.test("a"), "\\u{ Non-surrogate }"); assert(/(?.)/u.test("a"), "\\u{ Surrogate, ID_Continue }"); +assert(RegExp("(?<\u{0041}>.)", "u").test("a"), "Non-surrogate"); +assert(RegExp("(?.)", "u").test("a"), "Surrogate,ID_Continue"); assert((/(?<\u{0041}>.)/u).test("a"), "Non-surrogate"); assert(/(?.)/u.test("a"), "Surrogate, ID_Continue"); assert(RegExp("(?<\\u0041>.)", "u").test("a"), "Non-surrogate"); diff --git a/test/language/literals/regexp/named-groups/invalid-dangling-groupname-5.js b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-5.js new file mode 100644 index 0000000000..582bf29d8a --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-5.js @@ -0,0 +1,20 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Group reference must have corresponding group. +info: | + It is a Syntax Error if the enclosing Pattern does not contain a + GroupSpecifier with an enclosed RegExpIdentifierName whose StringValue + equals the StringValue of the RegExpIdentifierName of this production's + GroupName. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/\k(?x)/; diff --git a/test/language/literals/regexp/named-groups/invalid-lone-surrogate-groupname.js b/test/language/literals/regexp/named-groups/invalid-lone-surrogate-groupname.js new file mode 100644 index 0000000000..7be757996b --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-lone-surrogate-groupname.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Lone surrogates in RegExp group names +esid: prod-GroupSpecifier +features: [regexp-named-groups] +---*/ + +assert.throws(SyntaxError, () => eval("/(?.)/"), "Lead"); +assert.throws(SyntaxError, () => eval("/(?.)/"), "Trail"); +assert.throws(SyntaxError, () => eval("/(?.)/u"), "Lead with u flag"); +assert.throws(SyntaxError, () => eval("/(?.)/u"), "Trail with u flag"); diff --git a/test/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-3.js b/test/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-3.js deleted file mode 100644 index 38f70fc6de..0000000000 --- a/test/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-3.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: GroupSpecifier must be identifier-like. -esid: prod-GroupSpecifier -negative: - phase: parse - type: SyntaxError -features: [regexp-named-groups] ----*/ - -throw "Test262: This statement should not be evaluated."; - -/(?.)/; diff --git a/test/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-2.js b/test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier-2.js similarity index 77% rename from test/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-2.js rename to test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier-2.js index e840db0553..7d58dc86b0 100644 --- a/test/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-2.js +++ b/test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier-2.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: GroupSpecifier must be identifier-like. +description: \u{} escapes in GroupSpecifier allowed only in Unicode mode esid: prod-GroupSpecifier negative: phase: parse @@ -12,4 +12,4 @@ features: [regexp-named-groups] throw "Test262: This statement should not be evaluated."; -/(?.)/; +/(?<\u{03C0}>a)/; diff --git a/test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier.js b/test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier.js index 6dfd5e5755..53f7b96bf6 100644 --- a/test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier.js +++ b/test/language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier.js @@ -12,4 +12,4 @@ features: [regexp-named-groups] throw "Test262: This statement should not be evaluated."; -/(?<\u{0041}>a)/; +/(?<\u{0041}>.)/;