diff --git a/test/built-ins/RegExp/named-groups/non-unicode-malformed.js b/test/built-ins/RegExp/named-groups/non-unicode-malformed.js deleted file mode 100644 index 37d47a692a..0000000000 --- a/test/built-ins/RegExp/named-groups/non-unicode-malformed.js +++ /dev/null @@ -1,35 +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: > - Named groups in Unicode RegExps have some syntax errors and some - compatibility escape fallback behavior. -esid: prod-GroupSpecifier -features: [regexp-named-groups] -includes: [compareArray.js] ----*/ - -assert.throws(SyntaxError, () => eval("/(?<>a)/")); -assert.throws(SyntaxError, () => eval("/(? eval("/(?<42a>a)/")); -assert.throws(SyntaxError, () => eval("/(?<:a>a)/")); -assert.throws(SyntaxError, () => eval("/(?a)/")); -assert.throws(SyntaxError, () => eval("/(?a)(?a)/")); -assert.throws(SyntaxError, () => eval("/(?a)(?b)(?a)/")); - -assert.throws(SyntaxError, () => eval("/(?.)\\k/")); -assert.throws(SyntaxError, () => eval("/(?.)\\k eval("/(?.)\\k<>/")); -assert.throws(SyntaxError, () => eval("/(?.)\\k/")); -assert.throws(SyntaxError, () => eval("/(?a)\\k/")); -assert.throws(SyntaxError, () => eval("/(?a)\\k/")); -assert.throws(SyntaxError, () => eval("/\\k(?a)/")); -assert.throws(SyntaxError, () => eval("/\\ka)/")); - -// A couple of corner cases around '\k' as named back-references vs. identity -// escapes. -assert(/\k(?x)/.test("x")); -assert.throws(SyntaxError, () => eval("/\\k(?x)/")); -assert.throws(SyntaxError, () => eval("/\\k.)/")); -assert.throws(SyntaxError, () => eval("/\\k(?.)/")); diff --git a/test/language/literals/regexp/named-groups/forward-reference.js b/test/language/literals/regexp/named-groups/forward-reference.js new file mode 100644 index 0000000000..a6dd3c37f2 --- /dev/null +++ b/test/language/literals/regexp/named-groups/forward-reference.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Named groups can be forward references. +esid: sec-atomescape +features: [regexp-named-groups] +---*/ + +assert(/\k(?x)/.test("x")); diff --git a/test/language/literals/regexp/named-groups/invalid-dangling-groupname-2.js b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-2.js new file mode 100644 index 0000000000..ec03c951d7 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-2.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."; + +/(?a)\k/; diff --git a/test/language/literals/regexp/named-groups/invalid-dangling-groupname-3.js b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-3.js new file mode 100644 index 0000000000..48489ff589 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-3.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."; + +/(?a)\k/; diff --git a/test/language/literals/regexp/named-groups/invalid-dangling-groupname-4.js b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-4.js new file mode 100644 index 0000000000..fac6cad35e --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-dangling-groupname-4.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(?a)/; 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-dangling-groupname.js b/test/language/literals/regexp/named-groups/invalid-dangling-groupname.js new file mode 100644 index 0000000000..b215f8c46b --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-dangling-groupname.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/; diff --git a/test/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js b/test/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js new file mode 100644 index 0000000000..1ca18d9242 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupSpecifiers must be unique. +info: | + It is a Syntax Error if Pattern contains multiple GroupSpecifiers + whose enclosed RegExpIdentifierNames have the same StringValue. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/(?a)(?b)(?a)/; diff --git a/test/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js b/test/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js new file mode 100644 index 0000000000..1cbc8c2e27 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupSpecifiers must be unique. +info: | + It is a Syntax Error if Pattern contains multiple GroupSpecifiers + whose enclosed RegExpIdentifierNames have the same StringValue. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/(?a)(?a)/; diff --git a/test/language/literals/regexp/named-groups/invalid-empty-groupspecifier.js b/test/language/literals/regexp/named-groups/invalid-empty-groupspecifier.js new file mode 100644 index 0000000000..1050d96060 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-empty-groupspecifier.js @@ -0,0 +1,15 @@ +// 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."; + +/(?<>a)/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js new file mode 100644 index 0000000000..a5532fea0d --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupName is `< RegExpIdentifierName >`. +esid: prod-GroupName +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/(?.)\k`. +esid: prod-GroupName +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/(?.)\k<>/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js new file mode 100644 index 0000000000..0406bad509 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupName is `< RegExpIdentifierName >`. +esid: prod-GroupName +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/\ka)/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js new file mode 100644 index 0000000000..5f46988659 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupName is `< RegExpIdentifierName >`. +esid: prod-GroupName +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/\k.)/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js new file mode 100644 index 0000000000..88f9039386 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupName is `< RegExpIdentifierName >`. +esid: prod-GroupName +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/\k(?.)/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupname.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname.js new file mode 100644 index 0000000000..f660e1fa8d --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupName is `< RegExpIdentifierName >`. +esid: prod-GroupName +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +throw "Test262: This statement should not be evaluated."; + +/(?.)\k/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupspecifier.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupspecifier.js new file mode 100644 index 0000000000..6ccac1ce1e --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupspecifier.js @@ -0,0 +1,15 @@ +// 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."; + +/(?a)/; diff --git a/test/language/literals/regexp/named-groups/invalid-punctuator-in-groupspecifier-2.js b/test/language/literals/regexp/named-groups/invalid-punctuator-in-groupspecifier-2.js new file mode 100644 index 0000000000..8fec9b8ff9 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-punctuator-in-groupspecifier-2.js @@ -0,0 +1,15 @@ +// 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."; + +/(?a)/; diff --git a/test/language/literals/regexp/named-groups/invalid-punctuator-in-groupspecifier.js b/test/language/literals/regexp/named-groups/invalid-punctuator-in-groupspecifier.js new file mode 100644 index 0000000000..3e646904a1 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-punctuator-in-groupspecifier.js @@ -0,0 +1,15 @@ +// 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."; + +/(?<:a>a)/;