diff --git a/test/annexB/language/literals/regexp/class-escape.js b/test/annexB/language/literals/regexp/class-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..bbc0ada785a9b74a01a5331077677fca6e1c6e31 --- /dev/null +++ b/test/annexB/language/literals/regexp/class-escape.js @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Extensions to ClassEscape +info: | + ClassEscape[U] :: + b + [+U] - + [~U] c ClassControlLetter + CharacterClassEscape + CharacterEscape[?U] + + ClassControlLetter :: + DecimalDigit + _ + + The production ClassEscape :: c ClassControlLetter evaluates as follows: + + 1. Let ch be the character matched by ClassControlLetter. + 2. Let i be ch's character value. + 3. Let j be the remainder of dividing i by 32. + 4. Let d be the character whose character value is j. + 5. Return the CharSet containing the single character d. +---*/ + +var match; + +match = /\c0/.exec('\x0f\x10\x11'); +assert.sameValue(match, null, '\\c0 outside of CharacterClass'); + +match = /[\c0]/.exec('\x0f\x10\x11'); +assert.sameValue(match[0], '\x10', '\\c0 within CharacterClass'); + +match = /[\c00]+/.exec('\x0f0\x10\x11'); +assert.sameValue(match[0], '0\x10', '\\c00 within CharacterClass'); + +match = /\c1/.exec('\x10\x11\x12'); +assert.sameValue(match, null, '\\c1 outside of CharacterClass'); + +match = /[\c1]/.exec('\x10\x11\x12'); +assert.sameValue(match[0], '\x11', '\\c1 within CharacterClass'); + +match = /[\c10]+/.exec('\x100\x11\x12'); +assert.sameValue(match[0], '0\x11', '\\c10 within CharacterClass'); + +match = /\c8/.exec('\x17\x18\x19'); +assert.sameValue(match, null, '\\c8 outside of CharacterClass'); + +match = /[\c8]/.exec('\x17\x18\x19'); +assert.sameValue(match[0], '\x18', '\\c8 within CharacterClass'); + +match = /[\c80]+/.exec('\x170\x18\x19'); +assert.sameValue(match[0], '0\x18', '\\c80 within CharacterClass'); + +match = /\c9/.exec('\x18\x19\x1a'); +assert.sameValue(match, null, '\\c9 outside of CharacterClass'); + +match = /[\c9]/.exec('\x18\x19\x1a'); +assert.sameValue(match[0], '\x19', '\\c9 within CharacterClass'); + +match = /[\c90]+/.exec('\x180\x19\x1a'); +assert.sameValue(match[0], '0\x19', '\\c90 within CharacterClass'); + +match = /\c_/.exec('\x1e\x1f\x20'); +assert.sameValue(match, null, '\\c_ outside of CharacterClass'); + +match = /[\c_]/.exec('\x1e\x1f\x20'); +assert.sameValue(match[0], '\x1f', '\\c_ within CharacterClass'); diff --git a/test/annexB/language/literals/regexp/extended-pattern-char.js b/test/annexB/language/literals/regexp/extended-pattern-char.js new file mode 100644 index 0000000000000000000000000000000000000000..ec173f2d21ff200af1bbaf4c7ebee64320d8d854 --- /dev/null +++ b/test/annexB/language/literals/regexp/extended-pattern-char.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Extended Pattern Characters (as distinct from Pattern Characters) +info: | + ExtendedPatternCharacter :: + SourceCharacterbut not one of ^$.*+?()[| + + The production ExtendedAtom::ExtendedPatternCharacter evaluates as follows: + + 1. Let ch be the character represented by ExtendedPatternCharacter. + 2. Let A be a one-element CharSet containing the character ch. + 3. Call CharacterSetMatcher(A, false) and return its Matcher result. +---*/ + +var match; + +match = /]/.exec(' ]{}'); +assert.sameValue(match[0], ']'); + +match = /{/.exec(' ]{}'); +assert.sameValue(match[0], '{'); + +match = /}/.exec(' ]{}'); +assert.sameValue(match[0], '}'); + +match = /x{o}x/.exec('x{o}x'); +assert.sameValue(match[0], 'x{o}x'); diff --git a/test/annexB/language/literals/regexp/identity-escape.js b/test/annexB/language/literals/regexp/identity-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..8cc4ea2149dc86908be0d0731212d683634a434c --- /dev/null +++ b/test/annexB/language/literals/regexp/identity-escape.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Support for UnicodeIDContinue in IdentityEscape +info: | + IdentityEscape[U] :: + [+U] SyntaxCharacter + [+U] / + [~U] SourceCharacter but not c +---*/ + +var match; + +match = /\C/.exec('ABCDE'); +assert.sameValue(match[0], 'C'); + +match = /O\PQ/.exec('MNOPQRS'); +assert.sameValue(match[0], 'OPQ'); + +match = /\8/.exec('789'); +assert.sameValue(match[0], '8'); + +match = /7\89/.exec('67890'); +assert.sameValue(match[0], '789'); + +match = /\9/.exec('890'); +assert.sameValue(match[0], '9'); + +match = /8\90/.exec('78900'); +assert.sameValue(match[0], '890'); + +match = /(.)(.)(.)(.)(.)(.)(.)(.)\8\8/.exec('0123456777'); +assert.sameValue( + match[0], + '0123456777', + 'DecimalEscape takes precedence over IdentityEscape (\\8)' +); + +match = /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9\9/.exec('01234567888'); +assert.sameValue( + match[0], + '01234567888', + 'DecimalEscape takes precedence over IdentityEscape (\\9)' +); diff --git a/test/annexB/language/literals/regexp/legacy-octal-escape.js b/test/annexB/language/literals/regexp/legacy-octal-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..01eef78535e919b2899657a725d612930ab54de3 --- /dev/null +++ b/test/annexB/language/literals/regexp/legacy-octal-escape.js @@ -0,0 +1,61 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Legacy Octal Escape Sequence +info: | + CharacterEscape[U]:: + ControlEscape + c ControlLetter + 0 [lookahead ∉ DecimalDigit] + HexEscapeSequence + RegExpUnicodeEscapeSequence[?U] + [~U] LegacyOctalEscapeSequence + IdentityEscape[?U] + + The production CharacterEscape::LegacyOctalEscapeSequence evaluates by + evaluating the SV of the LegacyOctalEscapeSequence (see B.1.2) and + returning its character result. +---*/ + +var match; + +assert.sameValue(/\1/.exec('\x01')[0], '\x01', '\\1'); +assert.sameValue(/\2/.exec('\x02')[0], '\x02', '\\2'); +assert.sameValue(/\3/.exec('\x03')[0], '\x03', '\\3'); +assert.sameValue(/\4/.exec('\x04')[0], '\x04', '\\4'); +assert.sameValue(/\5/.exec('\x05')[0], '\x05', '\\5'); +assert.sameValue(/\6/.exec('\x06')[0], '\x06', '\\6'); +assert.sameValue(/\7/.exec('\x07')[0], '\x07', '\\7'); + +assert.sameValue(/\00/.exec('\x00')[0], '\x00', '\\00'); +assert.sameValue(/\07/.exec('\x07')[0], '\x07', '\\07'); + +assert.sameValue(/\30/.exec('\x18')[0], '\x18', '\\30'); +assert.sameValue(/\37/.exec('\x1f')[0], '\x1f', '\\37'); + +assert.sameValue(/\40/.exec('\x20')[0], '\x20', '\\40'); +assert.sameValue(/\47/.exec('\x27')[0], '\x27', '\\47'); + +assert.sameValue(/\70/.exec('\x38')[0], '\x38', '\\70'); +assert.sameValue(/\77/.exec('\x3f')[0], '\x3f', '\\77'); + +// Sequence is bounded according to the String Value (not number of characters) +assert.sameValue(/\400/.exec('\x200')[0], '\x200', '\\400'); +assert.sameValue(/\470/.exec('\x270')[0], '\x270', '\\470'); +assert.sameValue(/\700/.exec('\x380')[0], '\x380', '\\700'); +assert.sameValue(/\770/.exec('\x3f0')[0], '\x3f0', '\\770'); + +assert.sameValue(/\000/.exec('\x00')[0], '\x00', '\\000'); +assert.sameValue(/\007/.exec('\x07')[0], '\x07', '\\007'); +assert.sameValue(/\070/.exec('\x38')[0], '\x38', '\\070'); + +assert.sameValue(/\300/.exec('\xc0')[0], '\xc0', '\\300'); +assert.sameValue(/\307/.exec('\xc7')[0], '\xc7', '\\307'); +assert.sameValue(/\370/.exec('\xf8')[0], '\xf8', '\\370'); + +match = /(.)\1/.exec('a\x01 aa'); +assert.sameValue( + match[0], 'aa', 'DecimalEscape takes precedence over LegacyOctalEscapeSequence' +); diff --git a/test/annexB/language/literals/regexp/non-empty-class-ranges-no-dash.js b/test/annexB/language/literals/regexp/non-empty-class-ranges-no-dash.js new file mode 100644 index 0000000000000000000000000000000000000000..a91ec290b6d5e5245977bc9000d720cf9ff4728a --- /dev/null +++ b/test/annexB/language/literals/regexp/non-empty-class-ranges-no-dash.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Extensions to NonemptyClassRangesNoDash production +info: | + The production + NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates + as follows: + + 1. Evaluate ClassAtomNoDash to obtain a CharSet A. + 2. Evaluate ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRangeOrUnion(A, B) and let D be the resulting CharSet. + 5. Return the union of CharSets D and C. + + B.1.4.1.1 Runtime Semantics: CharacterRangeOrUnion Abstract Operation + + 1. If Unicode is false, then + a. If A does not contain exactly one character or B does not contain + exactly one character, then + i. Let C be the CharSet containing the single character - U+002D + (HYPHEN-MINUS). + ii. Return the union of CharSets A, B and C. + 2. Return CharacterRange(A, B). +---*/ + +var match; + +match = /[\d-a]+/.exec(':a0123456789-:'); +assert.sameValue(match[0], 'a0123456789-'); + +match = /[\d-az]+/.exec(':a0123456789z-:'); +assert.sameValue(match[0], 'a0123456789z-'); + +match = /[%-\d]+/.exec('&%0123456789-&'); +assert.sameValue(match[0], '%0123456789-'); + +match = /[%-\dz]+/.exec('&%0123456789z-&'); +assert.sameValue(match[0], '%0123456789z-'); + +match = /[\s-\d]+/.exec('& \t0123456789-&'); +assert.sameValue(match[0], ' \t0123456789-'); + +match = /[\s-\dz]+/.exec('& \t0123456789z-&'); +assert.sameValue(match[0], ' \t0123456789z-'); diff --git a/test/annexB/language/literals/regexp/non-empty-class-ranges.js b/test/annexB/language/literals/regexp/non-empty-class-ranges.js new file mode 100644 index 0000000000000000000000000000000000000000..932d87a8e3190c012a3e23031632e544b3b76f07 --- /dev/null +++ b/test/annexB/language/literals/regexp/non-empty-class-ranges.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Extensions to NonemptyClassRanges production +info: | + The production NonemptyClassRanges :: ClassAtom-ClassAtom ClassRanges + evaluates as follows: + + 1. Evaluate the first ClassAtom to obtain a CharSet A. + 2. Evaluate the second ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRangeOrUnion(A, B) and let D be the resulting CharSet. + 5. Return the union of CharSets D and C. + + B.1.4.1.1 Runtime Semantics: CharacterRangeOrUnion Abstract Operation + + 1. If Unicode is false, then + a. If A does not contain exactly one character or B does not contain + exactly one character, then + i. Let C be the CharSet containing the single character - U+002D + (HYPHEN-MINUS). + ii. Return the union of CharSets A, B and C. + 2. Return CharacterRange(A, B). +---*/ + +var match; + +match = /[--\d]+/.exec('.-0123456789-.'); +assert.sameValue(match[0], '-0123456789-'); + +match = /[--\dz]+/.exec('.-0123456789z-.'); +assert.sameValue(match[0], '-0123456789z-'); diff --git a/test/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js b/test/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js new file mode 100644 index 0000000000000000000000000000000000000000..a92b9018d888573a03f72786e377b066b9acda07 --- /dev/null +++ b/test/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Quantifiable assertions `?=` ("followed by") +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion :: + ( ?= Disjunction ) + ( ?! Disjunction ) + + The production Term::QuantifiableAssertionQuantifier evaluates the same as + the production Term::AtomQuantifier but with QuantifiableAssertion + substituted for Atom. + + The production Assertion::QuantifiableAssertion evaluates by evaluating + QuantifiableAssertion to obtain a Matcher and returning that Matcher. + + Assertion (21.2.2.6) evaluation rules for the Assertion::(?=Disjunction) + and Assertion::(?!Disjunction) productions are also used for the + QuantifiableAssertion productions, but with QuantifiableAssertion + substituted for Assertion. +---*/ + +var match; + +match = /.(?=Z)*/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: *'); + +match = /.(?=Z)+/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: +'); + +match = /.(?=Z)?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: ?'); + +match = /.(?=Z){2}/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits }'); + +match = /.(?=Z){2,}/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits , }'); + +match = /.(?=Z){2,3}/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue( + match[0], 'b', 'quantifier: { DecimalDigits , DecimalDigits }' +); + +match = /.(?=Z)*?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: * ?'); + +match = /.(?=Z)+?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: + ?'); + +match = /.(?=Z)??/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: ? ?'); + +match = /.(?=Z){2}?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits } ?'); + +match = /.(?=Z){2,}?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits , } ?'); + +match = /.(?=Z){2,3}?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue( + match[0], 'b', 'quantifier: { DecimalDigits , DecimalDigits } ?' +); diff --git a/test/annexB/language/literals/regexp/quantifiable-assertion-not-followed-by.js b/test/annexB/language/literals/regexp/quantifiable-assertion-not-followed-by.js new file mode 100644 index 0000000000000000000000000000000000000000..2463108d521a21fd6db625370ab0b41ba21d90fb --- /dev/null +++ b/test/annexB/language/literals/regexp/quantifiable-assertion-not-followed-by.js @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Quantifiable assertions `?!` ("not followed by") +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion:: + ( ?= Disjunction ) + ( ?! Disjunction ) + + The production Term::QuantifiableAssertionQuantifier evaluates the same as + the production Term::AtomQuantifier but with QuantifiableAssertion + substituted for Atom. + + The production Assertion::QuantifiableAssertion evaluates by evaluating + QuantifiableAssertion to obtain a Matcher and returning that Matcher. + + Assertion (21.2.2.6) evaluation rules for the Assertion::(?=Disjunction) + and Assertion::(?!Disjunction) productions are also used for the + QuantifiableAssertion productions, but with QuantifiableAssertion + substituted for Assertion. +---*/ + +var match; + +match = /[a-e](?!Z)*/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: *'); + +match = /[a-e](?!Z)+/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: +'); + +match = /[a-e](?!Z)?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: ?'); + +match = /[a-e](?!Z){2}/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits }'); + +match = /[a-e](?!Z){2,}/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits , }'); + +match = /[a-e](?!Z){2,3}/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue( + match[0], 'e', 'quantifier: { DecimalDigits , DecimalDigits }' +); + +match = /[a-e](?!Z)*?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: * ?'); + +match = /[a-e](?!Z)+?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: + ?'); + +match = /[a-e](?!Z)??/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: ? ?'); + +match = /[a-e](?!Z){2}?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits } ?'); + +match = /[a-e](?!Z){2,}?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits , } ?'); + +match = /[a-e](?!Z){2,3}?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue( + match[0], 'e', 'quantifier: { DecimalDigits , DecimalDigits } ?' +); diff --git a/test/language/literals/regexp/invalid-braced-quantifier-exact.js b/test/language/literals/regexp/invalid-braced-quantifier-exact.js new file mode 100644 index 0000000000000000000000000000000000000000..31ade39d4e05308ae3c2ee1b16de3b50a284ce77 --- /dev/null +++ b/test/language/literals/regexp/invalid-braced-quantifier-exact.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: Braced quantifier in an Atom position (exact count) +info: | + SyntaxCharacter :: one of + ^$\.*+?()[]{}| + + PatternCharacter :: + SourceCharacterbut not SyntaxCharacter + + Although Annex B extends the definition of Term to include + ExtendedPatternCharacter, it also introduces the InvalidBracedQuantifier + pattern with a higher precedence. This makes the SyntaxError for such + patterns consistent between Annex-B and non-Annex-B environments. +negative: SyntaxError +---*/ + +/{2}/; diff --git a/test/language/literals/regexp/invalid-braced-quantifier-lower.js b/test/language/literals/regexp/invalid-braced-quantifier-lower.js new file mode 100644 index 0000000000000000000000000000000000000000..48587fb6124bcb95d3e80d41e4f9a98a8df361a8 --- /dev/null +++ b/test/language/literals/regexp/invalid-braced-quantifier-lower.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: Braced quantifier in an Atom position (lower-bounds) +info: | + SyntaxCharacter :: one of + ^$\.*+?()[]{}| + + PatternCharacter :: + SourceCharacterbut not SyntaxCharacter + + Although Annex B extends the definition of Term to include + ExtendedPatternCharacter, it also introduces the InvalidBracedQuantifier + pattern with a higher precedence. This makes the SyntaxError for such + patterns consistent between Annex-B and non-Annex-B environments. +negative: SyntaxError +---*/ + +/{2,}/; diff --git a/test/language/literals/regexp/invalid-braced-quantifier-range.js b/test/language/literals/regexp/invalid-braced-quantifier-range.js new file mode 100644 index 0000000000000000000000000000000000000000..56cb830f4572af00f2fa3fc38bda7b8b5c655139 --- /dev/null +++ b/test/language/literals/regexp/invalid-braced-quantifier-range.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: Braced quantifier in an Atom position (range) +info: | + SyntaxCharacter :: one of + ^$\.*+?()[]{}| + + PatternCharacter :: + SourceCharacterbut not SyntaxCharacter + + Although Annex B extends the definition of Term to include + ExtendedPatternCharacter, it also introduces the InvalidBracedQuantifier + pattern with a higher precedence. This makes the SyntaxError for such + patterns consistent between Annex-B and non-Annex-B environments. +negative: SyntaxError +---*/ + +/{2,3}/; diff --git a/test/language/literals/regexp/u-invalid-char-esc.js b/test/language/literals/regexp/u-invalid-char-esc.js deleted file mode 100644 index f1efca70bb018c498588c1f5ecf1ed4b9312e749..0000000000000000000000000000000000000000 --- a/test/language/literals/regexp/u-invalid-char-esc.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Invalid character escape with `u` flag -info: > - An unterminated character escape produces a SyntaxError when the `u` flag - is set (regardless of Annex B extensions--see ES6 section B.1.4). -es6id: 21.2.1 -negative: SyntaxError ----*/ - -/\c/u; diff --git a/test/language/literals/regexp/u-invalid-char-range-a.js b/test/language/literals/regexp/u-invalid-char-range-a.js deleted file mode 100644 index e7c0d30985f0b3299128854c7e886076e8e5746c..0000000000000000000000000000000000000000 --- a/test/language/literals/regexp/u-invalid-char-range-a.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Invalid character class range with `u` flag (lower set size > 1) -info: > - 21.2.2.15.1 Runtime Semantics: CharacterRange Abstract Operation - - 1. If A does not contain exactly one character or B does not contain - exactly one character, throw a SyntaxError exception. -es6id: 21.2.2.15.1 -negative: SyntaxError ----*/ - -/[\w-a]/u; diff --git a/test/language/literals/regexp/u-invalid-char-range-b.js b/test/language/literals/regexp/u-invalid-char-range-b.js deleted file mode 100644 index 619d28be9bd022ce7717d99f42631a858199225c..0000000000000000000000000000000000000000 --- a/test/language/literals/regexp/u-invalid-char-range-b.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Invalid character class range with `u` flag (upper set size > 1) -info: > - 21.2.2.15.1 Runtime Semantics: CharacterRange Abstract Operation - - 1. If A does not contain exactly one character or B does not contain - exactly one character, throw a SyntaxError exception. -es6id: 21.2.2.15.1 -negative: SyntaxError ----*/ - -/[a-\w]/u; diff --git a/test/language/literals/regexp/u-invalid-class-escape.js b/test/language/literals/regexp/u-invalid-class-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..702f9ab7b5eb0a9b7f276343c30d6a08f69e34cd --- /dev/null +++ b/test/language/literals/regexp/u-invalid-class-escape.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: > + ClassEscape does not recognize "class control" patterns +info: | + ClassEscape[U] :: + b + [+U] - + CharacterClassEscape + CharacterEscape[?U] + + The `u` flag precludes the Annex B extension that enables this pattern. +negative: SyntaxError +---*/ + +/\c0/u; diff --git a/test/language/literals/regexp/u-invalid-extended-pattern-char.js b/test/language/literals/regexp/u-invalid-extended-pattern-char.js new file mode 100644 index 0000000000000000000000000000000000000000..a4a5a5df3f1f6415be4a0e164555d5c0fdcf4ea9 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-extended-pattern-char.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: Quantifiable assertions disallowed with `u` flag +info: | + The `u` flag precludes the use of extended pattern characters irrespective + of the presence of Annex B extensions. + + Term[U] :: + [~U] ExtendedAtom +negative: SyntaxError +---*/ + +/{/u; diff --git a/test/language/literals/regexp/u-invalid-identity-escape.js b/test/language/literals/regexp/u-invalid-identity-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..4f16bf0f40d8a60d85a50e42836ff0154a353f47 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-identity-escape.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: Support for UnicodeIDContinue in IdentityEscape +info: | + IdentityEscape[U] :: + [+U] SyntaxCharacter + [+U] / + [~U] SourceCharacter but not UnicodeIDContinue + + The `u` flag precludes the use of characters in UnicodeIDContinue + irrespective of the presence of Annex B extensions. +negative: SyntaxError +---*/ + +/\M/u; diff --git a/test/language/literals/regexp/u-invalid-legacy-octal-escape.js b/test/language/literals/regexp/u-invalid-legacy-octal-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..7c752422caee1dd7fe8e202b902c693af99a6eca --- /dev/null +++ b/test/language/literals/regexp/u-invalid-legacy-octal-escape.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-patterns +es6id: 21.2.1 +description: Legacy Octal Escape Sequence not supported with `u` flag +info: | + The `u` flag precludes the use of LegacyOctalEscapeSequence irrespective + of the presence of Annex B extensions. + + CharacterEscape [U] :: + ControlEscape + c ControlLetter + 0[lookahead ∉ DecimalDigit] + HexEscapeSequence + RegExpUnicodeEscapeSequence[?U] + IdentityEscape[?U] +negative: SyntaxError +---*/ + +/\1/u; diff --git a/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js b/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js new file mode 100644 index 0000000000000000000000000000000000000000..5b8e427b501e512637f23656410cf8fb7fa0ad14 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-pattern-semantics +es6id: 21.2.2 +description: > + NonEmptyClassRangesNoDash production cannot specify a multi-character set + ("A" parameter) +info: | + The production + NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates + as follows: + + 1. Evaluate ClassAtomNoDash to obtain a CharSet A. + 2. Evaluate ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRange(A, B) and let D be the resulting CharSet. + + 21.2.2.15.1 Runtime Semantics: CharacterRange Abstract Operation + + 1. If A does not contain exactly one character or B does not contain + exactly one character, throw a SyntaxError exception. + + The `u` flag precludes the Annex B extension that enables this pattern. +negative: SyntaxError +---*/ + +/[\d-a]/u; diff --git a/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js b/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js new file mode 100644 index 0000000000000000000000000000000000000000..cd41a927ebceee108a9e5e6b4007d0344169c282 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-pattern-semantics +es6id: 21.2.2 +description: > + NonEmptyClassRangesNoDash production cannot specify a multi-character set + (both "A" and "B" parameters) +info: | + The production + NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates + as follows: + + 1. Evaluate ClassAtomNoDash to obtain a CharSet A. + 2. Evaluate ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRange(A, B) and let D be the resulting CharSet. + + 21.2.2.15.1 Runtime Semantics: CharacterRange Abstract Operation + + 1. If A does not contain exactly one character or B does not contain + exactly one character, throw a SyntaxError exception. + + The `u` flag precludes the Annex B extension that enables this pattern. +negative: SyntaxError +---*/ + +/[\s-\d]/u; diff --git a/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js b/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js new file mode 100644 index 0000000000000000000000000000000000000000..54b8ff674e882a709f4733dc76998d4f031ed6ad --- /dev/null +++ b/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-pattern-semantics +es6id: 21.2.2 +description: > + NonEmptyClassRangesNoDash production cannot specify a multi-character set + ("B" parameter) +info: | + The production + NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates + as follows: + + 1. Evaluate ClassAtomNoDash to obtain a CharSet A. + 2. Evaluate ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRange(A, B) and let D be the resulting CharSet. + + 21.2.2.15.1 Runtime Semantics: CharacterRange Abstract Operation + + 1. If A does not contain exactly one character or B does not contain + exactly one character, throw a SyntaxError exception. + + The `u` flag precludes the Annex B extension that enables this pattern. +negative: SyntaxError +---*/ + +/[%-\d]/u; diff --git a/test/language/literals/regexp/u-invalid-non-empty-class-ranges.js b/test/language/literals/regexp/u-invalid-non-empty-class-ranges.js new file mode 100644 index 0000000000000000000000000000000000000000..2187096539e7f162347e2fca4154bf2dc3e541dc --- /dev/null +++ b/test/language/literals/regexp/u-invalid-non-empty-class-ranges.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-pattern-semantics +es6id: 21.2.2 +description: > + NonEmptyClassRangesNoDash production cannot specify a multi-character set +info: | + The production + NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates + as follows: + + 1. Evaluate ClassAtomNoDash to obtain a CharSet A. + 2. Evaluate ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRange(A, B) and let D be the resulting CharSet. + + 21.2.2.15.1 Runtime Semantics: CharacterRange Abstract Operation + + 1. If A does not contain exactly one character or B does not contain + exactly one character, throw a SyntaxError exception. + + The `u` flag precludes the Annex B extension that enables this pattern. +negative: SyntaxError +---*/ + +/[--\d]/u; diff --git a/test/language/literals/regexp/u-invalid-oob-decimal-escape.js b/test/language/literals/regexp/u-invalid-oob-decimal-escape.js new file mode 100644 index 0000000000000000000000000000000000000000..bbebbe1070710057edc0f3627c9c34534b1024d9 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-oob-decimal-escape.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-pattern-semantics +es6id: 21.2.2 +description: Out-of-bounds decimal escapes +info: | + 1. Evaluate DecimalEscape to obtain an integer n. + 2. If n>NcapturingParens, throw a SyntaxError exception. + + When the "unicode" flag is set, this algorithm is honored irrespective of + the presence of Annex B extensions. +negative: SyntaxError +---*/ + +/\8/u; diff --git a/test/language/literals/regexp/u-invalid-quantifiable-assertion.js b/test/language/literals/regexp/u-invalid-quantifiable-assertion.js new file mode 100644 index 0000000000000000000000000000000000000000..a26d51282d7d6c055a5915dc44eb98c96ace90a0 --- /dev/null +++ b/test/language/literals/regexp/u-invalid-quantifiable-assertion.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B1.4 +description: Quantifiable assertions disallowed with `u` flag +info: | + The `u` flag precludes quantifiable assertions (even when Annex B is + honored) + + Term[U] :: + [~U] QuantifiableAssertion Quantifier +negative: SyntaxError +---*/ + +/.(?=.)?/u;