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 37d47a692a2acf2c8ad2b4db9d6c70de3828d52c..0000000000000000000000000000000000000000 --- 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("/(?<aa)/")); -assert.throws(SyntaxError, () => eval("/(?<42a>a)/")); -assert.throws(SyntaxError, () => eval("/(?<:a>a)/")); -assert.throws(SyntaxError, () => eval("/(?<a:>a)/")); -assert.throws(SyntaxError, () => eval("/(?<a>a)(?<a>a)/")); -assert.throws(SyntaxError, () => eval("/(?<a>a)(?<b>b)(?<a>a)/")); - -assert.throws(SyntaxError, () => eval("/(?<a>.)\\k/")); -assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<a/")); -assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<>/")); -assert.throws(SyntaxError, () => eval("/(?<a>.)\\k<b>/")); -assert.throws(SyntaxError, () => eval("/(?<a>a)\\k<ab>/")); -assert.throws(SyntaxError, () => eval("/(?<ab>a)\\k<a>/")); -assert.throws(SyntaxError, () => eval("/\\k<a>(?<ab>a)/")); -assert.throws(SyntaxError, () => eval("/\\k<a(?<a>a)/")); - -// A couple of corner cases around '\k' as named back-references vs. identity -// escapes. -assert(/\k<a>(?<a>x)/.test("x")); -assert.throws(SyntaxError, () => eval("/\\k<a>(?<b>x)/")); -assert.throws(SyntaxError, () => eval("/\\k<a(?<a>.)/")); -assert.throws(SyntaxError, () => eval("/\\k(?<a>.)/")); 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 0000000000000000000000000000000000000000..a6dd3c37f2a5cae179c46c2de617f5e93181808b --- /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<a>(?<a>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 0000000000000000000000000000000000000000..ec03c951d73b6f6fe6182f0b59093be86465da73 --- /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>a)\k<ab>/; 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 0000000000000000000000000000000000000000..48489ff58924185cc458539e6a6ffa45b7332fa7 --- /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."; + +/(?<ab>a)\k<a>/; 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 0000000000000000000000000000000000000000..fac6cad35ee31c81d161288c1b6466e8e71db5cb --- /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>(?<ab>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 0000000000000000000000000000000000000000..582bf29d8a4d17492c77eec19ea2d43fd89459a0 --- /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<a>(?<b>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 0000000000000000000000000000000000000000..b215f8c46b14f754246a49ac66bbb1fb9926855e --- /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."; + +/(?<a>.)\k<b>/; 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 0000000000000000000000000000000000000000..1ca18d9242acceb040bb91d078b79383ed23156b --- /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>a)(?<b>b)(?<a>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 0000000000000000000000000000000000000000..1cbc8c2e27ea97bb69d18042763895bfa3a48f39 --- /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)(?<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 0000000000000000000000000000000000000000..1050d96060dc3a2ddb6bf6f011cd24a43b4b14d7 --- /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 0000000000000000000000000000000000000000..a5532fea0d3959c1f6a1d12b504911444be4de9c --- /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."; + +/(?<a>.)\k<a/; diff --git a/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-3.js b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-3.js new file mode 100644 index 0000000000000000000000000000000000000000..9fe83adaae0c6b6a55da04158be14a21c5c5bbb6 --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-incomplete-groupname-3.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."; + +/(?<a>.)\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 0000000000000000000000000000000000000000..0406bad50917e4eee8386ba18681fab6b4fbf0a8 --- /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."; + +/\k<a(?<a>a)/; 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 0000000000000000000000000000000000000000..5f46988659700ed653ef8a9130cca2b3bb26abe4 --- /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<a(?<a>.)/; 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 0000000000000000000000000000000000000000..88f90393861c61bee7af32e12a3bcfc45c397f54 --- /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(?<a>.)/; 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 0000000000000000000000000000000000000000..f660e1fa8d7d170cb861835fa8e4ecfe106e74ca --- /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."; + +/(?<a>.)\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 0000000000000000000000000000000000000000..6ccac1ce1eb58d3ae3741217512e7430154e2f65 --- /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."; + +/(?<aa)/; diff --git a/test/language/literals/regexp/named-groups/invalid-numeric-groupspecifier.js b/test/language/literals/regexp/named-groups/invalid-numeric-groupspecifier.js new file mode 100644 index 0000000000000000000000000000000000000000..235e780734a1685ec9983bcb9b42e46d66701a0e --- /dev/null +++ b/test/language/literals/regexp/named-groups/invalid-numeric-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."; + +/(?<42a>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 0000000000000000000000000000000000000000..8fec9b8ff91ada92161765abf218b80e0f14bd72 --- /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:>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 0000000000000000000000000000000000000000..3e646904a103cd4dec747e9e2aec3077e02ad3a1 --- /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)/;