diff options
Diffstat (limited to 'js/src/tests/test262/language/literals/regexp')
159 files changed, 3821 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/literals/regexp/7.8.5-1.js b/js/src/tests/test262/language/literals/regexp/7.8.5-1.js new file mode 100644 index 0000000000..8eacd910c9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/7.8.5-1.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + SyntaxError exception is thrown if the RegularExpressionNonTerminator position of a + RegularExpressionBackslashSequence is a LineTerminator. +description: > + A RegularExpressionBackslashSequence may not contain a LineTerminator. +---*/ + +assert.throws(SyntaxError, function() { + eval("/\\\rn/;"); +/* + +The result of this string is: + +"/\ +n/;" + +*/ +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/7.8.5-1gs.js b/js/src/tests/test262/language/literals/regexp/7.8.5-1gs.js new file mode 100644 index 0000000000..567cb28010 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/7.8.5-1gs.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionLiteral :: + / RegularExpressionBody / RegularExpressionFlags + + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + SourceCharacter :: + any Unicode code point + + RegularExpressionNonTerminator:: + SourceCharacter but not LineTerminator + +description: > + RegularExpressionBody will never be empty, because RegularExpressionFirstChar must always be _something_. // is a comment. +---*/ + +var y = 42; +var x = //.source; +y; + +assert.sameValue(x, y); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/7.8.5-2gs.js b/js/src/tests/test262/language/literals/regexp/7.8.5-2gs.js new file mode 100644 index 0000000000..f9b1d3f6b9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/7.8.5-2gs.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.8.5-2gs +description: Empty dynamic RegExp should not result in a SyntaxError +---*/ + +var re = new RegExp(""); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.1_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.1_T1.js new file mode 100644 index 0000000000..ff1c5f83ab --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.1_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionFirstChar :: NonTerminator but not * or \ or /, + RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty] +es5id: 7.8.5_A1.1_T1 +description: Without eval +---*/ + +//CHECK#1 +if (/1/.source !== "1") { + throw new Test262Error('#1: /1/'); +} + +//CHECK#2 +if (/a/.source !== "a") { + throw new Test262Error('#2: /a/'); +} + +//CHECK#3 +if (/;/.source !== ";") { + throw new Test262Error('#3: /;/'); +} + +//CHECK#4 +if (/ /.source !== " ") { + throw new Test262Error('#4: / /'); +} + +//CHECK#5 +if (/\u0041/.source !== "\\u0041") { + throw new Test262Error('#5: /\\u0041/'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.1_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.1_T2.js new file mode 100644 index 0000000000..08383b6495 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.1_T2.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionFirstChar :: NonTerminator but not * or \ or /, + RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty] +es5id: 7.8.5_A1.1_T2 +description: Complex test with eval, using syntax pattern +---*/ + +for (var cu = 0; cu <= 0xffff; ++cu) { + var Elimination = + ((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) || + (cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) || + (cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D)); + /* + * \u002A / \u002F \ \u005C + \u002B + ? \u003F ( \u0028 ) \u0029 + [ \u005B ] \u005D { \u007B } \u007D + */ + var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029)); + if ((Elimination || LineTerminator ) === false) { + var xx = String.fromCharCode(cu); + var pattern = eval("/" + xx + "/"); + assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T1.js new file mode 100644 index 0000000000..21f3e624cb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T1.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionFirstChar +info: | + RegularExpressionChars :: + [empty] + RegularExpressionCharsRegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + +description: > + The first character of a regular expression may not be "*" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/*/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T2.js new file mode 100644 index 0000000000..16c3d38d71 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T2.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + +description: > + The first character of a regular expression may not be "\" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T3.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T3.js new file mode 100644 index 0000000000..891aaa9c1f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T3.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + +description: > + The first character of a regular expression may not be "/" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/// +.source; diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T4.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T4.js new file mode 100644 index 0000000000..008979ed1a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.2_T4.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionLiteral:: + / RegularExpressionBody / RegularExpressionFlags + + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars:: + [empty] + + MemberExpression . IdentifierName + +description: A regular expression may not be empty. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +// +.source; diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T1.js new file mode 100644 index 0000000000..5264fd86b1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T1.js @@ -0,0 +1,31 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <LF> (\u000A) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/ +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T2.js new file mode 100644 index 0000000000..4919cb6498 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T2.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <LF> (\u000A), evaluated +---*/ + +//CHECK#1 +try { + eval("/\u000A/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: Line Feed is incorrect. Actual: ' + (eval("/\u000A/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: Line Feed is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T3.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T3.js new file mode 100644 index 0000000000..11fd813618 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T3.js @@ -0,0 +1,31 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <CR>, (\u000D) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/ +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T4.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T4.js new file mode 100644 index 0000000000..e22f4e21be --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T4.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <CR>, (\u000D), evaluated +---*/ + +//CHECK#1 +try { + eval("/\u000D/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: Carriage Return is incorrect. Actual: ' + (eval("/\u000D/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: Carriage Return is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T5.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T5.js new file mode 100644 index 0000000000..2111c61459 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T5.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <LS>, (\u2028), evaluated + +---*/ + +//CHECK#1 +try { + eval("/\u2028/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: Line separator is incorrect. Actual: ' + (eval("/\u2028/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: Line separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T6.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T6.js new file mode 100644 index 0000000000..e004a50813 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.3_T6.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <LS>, (\u2028), evaluated +---*/ + +//CHECK#1 +try { + eval("/\u2029/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: Paragraph separator is incorrect. Actual: ' + (eval("/\u2029/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: Paragraph separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.4_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.4_T1.js new file mode 100644 index 0000000000..018d8d463c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.4_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionFirstChar :: BackslashSequence :: \NonTerminator, + RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty] +es5id: 7.8.5_A1.4_T1 +description: Check similar to (/\;/.source === "\\;") +---*/ + +//CHECK#1 +if (/\;/.source !== "\\;") { + throw new Test262Error('#1: /\\;/'); +} + +//CHECK#2 +if (/\ /.source !== "\\ ") { + throw new Test262Error('#2: /\\ /'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.4_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.4_T2.js new file mode 100644 index 0000000000..528e414400 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.4_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionFirstChar :: BackslashSequence :: \NonTerminator, + RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty] +es5id: 7.8.5_A1.4_T2 +description: Complex test with eval, using syntax pattern +---*/ + +for (var cu = 0; cu <= 0xffff; ++cu) { + var Elimination = + ((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) || + (cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) || + (cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D)); + /* + * \u002A / \u002F \ \u005C + \u002B + ? \u003F ( \u0028 ) \u0029 + [ \u005B ] \u005D { \u007B } \u007D + */ + var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029)); + if ((Elimination || LineTerminator ) === false) { + var xx = "\\" + String.fromCharCode(cu); + try { + var pattern = eval("/" + xx + "/"); + } catch (e) { + var identifierPartNotUnicodeIDContinue = ((cu === 0x0024) || (cu === 0x200C) || (cu === 0x200D)); + if (e instanceof SyntaxError && !identifierPartNotUnicodeIDContinue) { + // Use eval with var-declaration to check if `cu` is in UnicodeIDContinue. + try { + eval("var _" + String.fromCharCode(cu)); + continue; + } catch (ignore) { } + } + throw e; + } + assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T1.js new file mode 100644 index 0000000000..0de1c6a6a9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T1.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A RegularExpressionBackslashSequence may not contain a <LF> + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\ +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T2.js new file mode 100644 index 0000000000..45adbfaec4 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T2.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A RegularExpressionBackslashSequence may not contain a <LF>, evaluated + +---*/ + +//CHECK#1 +try { + eval("/\\\u000A/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: BackslashSequence :: \\Line Feed is incorrect. Actual: ' + (eval("/\\\u000A/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: BackslashSequence :: \\Line Feed is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T3.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T3.js new file mode 100644 index 0000000000..d4003bf348 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T3.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A RegularExpressionBackslashSequence may not contain a <CR> +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\ +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T4.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T4.js new file mode 100644 index 0000000000..b5962c12b3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A RegularExpressionBackslashSequence may not contain a <CR>, evaluated +---*/ + +//CHECK#1 +try { + eval("/\\\u000D/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: BackslashSequence :: \\Carriage Return is incorrect. Actual: ' + (eval("/\\\u000D/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: BackslashSequence :: \\Carriage Return is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T5.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T5.js new file mode 100644 index 0000000000..86e90a5744 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T5.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <LS>, (\u2028), evaluated +---*/ + +//CHECK#1 +try { + eval("/\\\u2028/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: BackslashSequence :: \\Line separator is incorrect. Actual: ' + (eval("/\\\u2028/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: BackslashSequence :: \\Line separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T6.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T6.js new file mode 100644 index 0000000000..5fb0b9b08c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A1.5_T6.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <PS>, (\u2029), evaluated +---*/ + +//CHECK#1 +try { + eval("/\\\u2029/").source; + throw new Test262Error('#1.1: RegularExpressionFirstChar :: BackslashSequence :: \\Paragraph separator is incorrect. Actual: ' + (eval("/\\\u2029/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionFirstChar :: BackslashSequence :: \\Paragraph separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.1_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.1_T1.js new file mode 100644 index 0000000000..9cad6dddc3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.1_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionChar :: NonTerminator but not \ or /, + RegularExpressionFlags :: [empty] +es5id: 7.8.5_A2.1_T1 +description: Without eval +---*/ + +//CHECK#1 +if (/1a/.source !== "1a") { + throw new Test262Error('#1: /1a/'); +} + +//CHECK#2 +if (/aa/.source !== "aa") { + throw new Test262Error('#2: /aa/'); +} + +//CHECK#3 +if (/,;/.source !== ",;") { + throw new Test262Error('#3: /,;/'); +} + +//CHECK#4 +if (/ /.source !== " ") { + throw new Test262Error('#4: / /'); +} + +//CHECK#5 +if (/a\u0041/.source !== "a\\u0041") { + throw new Test262Error('#5: /a\\u0041/'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.1_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.1_T2.js new file mode 100644 index 0000000000..d077c89fed --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.1_T2.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionChar :: NonTerminator but not \ or /, + RegularExpressionFlags :: [empty] +es5id: 7.8.5_A2.1_T2 +description: Complex test with eval, using syntax pattern +---*/ + +for (var cu = 0; cu <= 0xffff; ++cu) { + var Elimination = + ((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) || + (cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) || + (cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D)); + /* + * \u002A / \u002F \ \u005C + \u002B + ? \u003F ( \u0028 ) \u0029 + [ \u005B ] \u005D { \u007B } \u007D + */ + var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029)); + if ((Elimination || LineTerminator ) === false) { + var xx = "nnnn" + String.fromCharCode(cu); + var pattern = eval("/" + xx + "/"); + assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.2_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.2_T1.js new file mode 100644 index 0000000000..603b348ecf --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.2_T1.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionChar +info: | + RegularExpressionChar :: + RegularExpressionNonTerminator but not one of \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A regular express may not contain a "\" as a SourceCharacter + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a\/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.2_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.2_T2.js new file mode 100644 index 0000000000..96682b6af1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.2_T2.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionChar +info: | + RegularExpressionChar :: + RegularExpressionNonTerminator but not one of \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A regular expression may not contain a "/" as a SourceCharacter + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a//.source; diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T1.js new file mode 100644 index 0000000000..1f463af56c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T1.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionChar :: + RegularExpressionBackslashSequence + + + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LF> as a SourceCharacter +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T2.js new file mode 100644 index 0000000000..a63f1777c9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionChar :: + RegularExpressionBackslashSequence + + + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LF> as a SourceCharacter, evaluated +---*/ + +//CHECK#1 +try { + eval("/a\u000A/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: Line Feedis incorrect. Actual: ' + (eval("/a\u000A/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: Line Feed is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T3.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T3.js new file mode 100644 index 0000000000..5bf93016ab --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T3.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionChar :: + RegularExpressionBackslashSequence + + + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <CR> as a SourceCharacter + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T4.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T4.js new file mode 100644 index 0000000000..e04f5f5622 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-regular-expression-literals +info: | + RegularExpressionChar :: + RegularExpressionBackslashSequence + + + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <CR> as a SourceCharacter, evaluated +---*/ + +//CHECK#1 +try { + eval("/a\u000D/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: Carriage Retur is incorrect. Actual: ' + (eval("/a\u000D/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: Carriage Retur is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T5.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T5.js new file mode 100644 index 0000000000..e4643f98bc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T5.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A regular expression may not contain a <LS> as a SourceCharacter, evaluated + +---*/ + +//CHECK#1 +try { + eval("/a\u2028/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: Line separator is incorrect. Actual: ' + (eval("/a\u2028/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: Line separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T6.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T6.js new file mode 100644 index 0000000000..3985c50fbd --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.3_T6.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A regular expression may not contain a <PS> as a SourceCharacter, evaluated + +---*/ + +try { + eval("/s\u2029/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: Paragraph separator is incorrect. Actual: ' + (eval("/s\u2029/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: Paragraph separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.4_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.4_T1.js new file mode 100644 index 0000000000..cc4668832c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.4_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionChar :: BackslashSequence :: \NonTerminator, + RegularExpressionFlags :: [empty] +es5id: 7.8.5_A2.4_T1 +description: Check similar to (/,\;/.source === ",\\;") +---*/ + +//CHECK#1 +if (/,\;/.source !== ",\\;") { + throw new Test262Error('#1: /,\\;/'); +} + +//CHECK#2 +if (/ \ /.source !== " \\ ") { + throw new Test262Error('#2: / \\ /'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.4_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.4_T2.js new file mode 100644 index 0000000000..565997cd92 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.4_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegularExpressionChar :: BackslashSequence :: \NonTerminator, + RegularExpressionFlags :: [empty] +es5id: 7.8.5_A2.4_T2 +description: Complex test with eval, using syntax pattern +---*/ + +for (var cu = 0; cu <= 0xffff; ++cu) { + var Elimination = + ((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) || + (cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) || + (cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D)); + /* + * \u002A / \u002F \ \u005C + \u002B + ? \u003F ( \u0028 ) \u0029 + [ \u005B ] \u005D { \u007B } \u007D + */ + var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029)); + if ((Elimination || LineTerminator ) === false) { + var xx = "a\\" + String.fromCharCode(cu); + try { + var pattern = eval("/" + xx + "/"); + } catch (e) { + var identifierPartNotUnicodeIDContinue = ((cu === 0x0024) || (cu === 0x200C) || (cu === 0x200D)); + if (e instanceof SyntaxError && !identifierPartNotUnicodeIDContinue) { + // Use eval with var-declaration to check if `cu` is in UnicodeIDContinue. + try { + eval("var _" + String.fromCharCode(cu)); + continue; + } catch (ignore) { } + } + throw e; + } + assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T1.js new file mode 100644 index 0000000000..7599dabd48 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T1.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LF> as a SourceCharacter +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a\ +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T2.js new file mode 100644 index 0000000000..d7e66cb046 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T2.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LF> as a SourceCharacter, evaluated +---*/ + +//CHECK#1 +try { + eval("/a\\\u000A/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: BackslashSequence :: \\Line Feed is incorrect. Actual: ' + (eval("/a\\\u000A/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: BackslashSequence :: \\Line Feed is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T3.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T3.js new file mode 100644 index 0000000000..8f1329314c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T3.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <CR> as a SourceCharacter +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a\ +/ diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T4.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T4.js new file mode 100644 index 0000000000..fbdfbc62c2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T4.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LF> as a SourceCharacter, evaluated +---*/ + +//CHECK#1 +try { + eval("/a\\\u000D/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: BackslashSequence :: \\Carriage Return is incorrect. Actual: ' + (eval("/a\\\u000D/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: BackslashSequence :: \\Carriage Return is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T5.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T5.js new file mode 100644 index 0000000000..2bbcd18acf --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T5.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LS> as a SourceCharacter, evaluated +---*/ + +//CHECK#1 +try { + eval("/a\\\u2028/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: BackslashSequence :: \\Line separator is incorrect. Actual: ' + (eval("/a\\\u2028/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: BackslashSequence :: \\Line separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T6.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T6.js new file mode 100644 index 0000000000..538a786925 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A2.5_T6.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <PS> as a SourceCharacter, evaluated +---*/ + +//CHECK#1 +try { + eval("/a\\\u2029/").source; + throw new Test262Error('#1.1: RegularExpressionChar :: BackslashSequence :: \\Paragraph separator is incorrect. Actual: ' + (eval("/a\\\u2029/").source)); +} +catch (e) { + if ((e instanceof SyntaxError) !== true) { + throw new Test262Error('#1.2: RegularExpressionChar :: BackslashSequence :: \\Paragraph separator is incorrect. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T1.js new file mode 100644 index 0000000000..2719ec3f46 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T1.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "RegularExpressionFlags :: IdentifierPart" +es5id: 7.8.5_A3.1_T1 +description: "IdentifierPart :: g" +---*/ + +//CHECK#1 +var regexp = /(?:)/g; +if (regexp.global !== true) { + throw new Test262Error('#1: var regexp = /(?:)/g; regexp.global === true. Actual: ' + (regexp.global)); +} + +//CHECK#2 +if (regexp.ignoreCase !== false) { + throw new Test262Error('#2: var regexp = /(?:)/g; regexp.ignoreCase === false. Actual: ' + (regexp.ignoreCase)); +} + +//CHECK#3 +if (regexp.multiline !== false) { + throw new Test262Error('#3: var regexp = /(?:)/g; regexp.multiline === false. Actual: ' + (regexp.multiline)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T2.js new file mode 100644 index 0000000000..02f9a8edbf --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "RegularExpressionFlags :: IdentifierPart" +es5id: 7.8.5_A3.1_T2 +description: "IdentifierPart :: i" +---*/ + +//CHECK#1 +var regexp = /(?:)/i; +if (regexp.global !== false) { + throw new Test262Error('#1: var regexp = /(?:)/g; regexp.global === false. Actual: ' + (regexp.global)); +} + +//CHECK#2 +if (regexp.ignoreCase !== true) { + throw new Test262Error('#2: var regexp = /(?:)/g; regexp.ignoreCase === true. Actual: ' + (regexp.ignoreCase)); +} + +//CHECK#3 +if (regexp.multiline !== false) { + throw new Test262Error('#3: var regexp = /(?:)/g; regexp.multiline === false. Actual: ' + (regexp.multiline)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T3.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T3.js new file mode 100644 index 0000000000..d349d6e765 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T3.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "RegularExpressionFlags :: IdentifierPart" +es5id: 7.8.5_A3.1_T3 +description: "IdentifierPart :: m" +---*/ + +//CHECK#1 +var regexp = /(?:)/m; +if (regexp.global !== false) { + throw new Test262Error('#1: var regexp = /(?:)/g; regexp.global === false. Actual: ' + (regexp.global)); +} + +//CHECK#2 +if (regexp.ignoreCase !== false) { + throw new Test262Error('#2: var regexp = /(?:)/g; regexp.ignoreCase === false. Actual: ' + (regexp.ignoreCase)); +} + +//CHECK#3 +if (regexp.multiline !== true) { + throw new Test262Error('#3: var regexp = /(?:)/g; regexp.multiline === true. Actual: ' + (regexp.multiline)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T4.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T4.js new file mode 100644 index 0000000000..0449010aa3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T4.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "RegularExpressionFlags :: IdentifierPart" +es5id: 7.8.5_A3.1_T4 +description: "IdentifierPart :: gi" +---*/ + +//CHECK#1 +var regexp = /(?:)/gi; +if (regexp.global !== true) { + throw new Test262Error('#1: var regexp = /(?:)/g; regexp.global === true. Actual: ' + (regexp.global)); +} + +//CHECK#2 +if (regexp.ignoreCase !== true) { + throw new Test262Error('#2: var regexp = /(?:)/g; regexp.ignoreCase === true. Actual: ' + (regexp.ignoreCase)); +} + +//CHECK#3 +if (regexp.multiline !== false) { + throw new Test262Error('#3: var regexp = /(?:)/g; regexp.multiline === false. Actual: ' + (regexp.multiline)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T5.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T5.js new file mode 100644 index 0000000000..3e3f649fa1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T5.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "RegularExpressionFlags :: IdentifierPart" +es5id: 7.8.5_A3.1_T5 +description: "IdentifierPart :: mg" +---*/ + +//CHECK#1 +var regexp = /(?:)/mg; +if (regexp.global !== true) { + throw new Test262Error('#1: var regexp = /(?:)/g; regexp.global === true. Actual: ' + (regexp.global)); +} + +//CHECK#2 +if (regexp.ignoreCase !== false) { + throw new Test262Error('#2: var regexp = /(?:)/g; regexp.ignoreCase === false. Actual: ' + (regexp.ignoreCase)); +} + +//CHECK#3 +if (regexp.multiline !== true) { + throw new Test262Error('#3: var regexp = /(?:)/g; regexp.multiline === true. Actual: ' + (regexp.multiline)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T6.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T6.js new file mode 100644 index 0000000000..1f66426320 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A3.1_T6.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "RegularExpressionFlags :: IdentifierPart" +es5id: 7.8.5_A3.1_T6 +description: "IdentifierPart :: mig" +---*/ + +//CHECK#1 +var regexp = /(?:)/mig; +if (regexp.global !== true) { + throw new Test262Error('#1: var regexp = /(?:)/g; regexp.global === true. Actual: ' + (regexp.global)); +} + +//CHECK#2 +if (regexp.ignoreCase !== true) { + throw new Test262Error('#2: var regexp = /(?:)/g; regexp.ignoreCase === true. Actual: ' + (regexp.ignoreCase)); +} + +//CHECK#3 +if (regexp.multiline !== true) { + throw new Test262Error('#3: var regexp = /(?:)/g; regexp.multiline === true. Actual: ' + (regexp.multiline)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A4.1.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A4.1.js new file mode 100644 index 0000000000..8de2e9dd27 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A4.1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A regular expression literal is an input element that is converted to + a RegExp object when it is scanned +es5id: 7.8.5_A4.1 +description: "Check ((/(?:)/ instanceof RegExp) === true)" +---*/ + +//CHECK#1 +if ((/(?:)/ instanceof RegExp) !== true) { + throw new Test262Error('#1: (/(?:)/ instanceof RegExp) === true. Actual: ' + ((/(?:)/ instanceof RegExp))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/S7.8.5_A4.2.js b/js/src/tests/test262/language/literals/regexp/S7.8.5_A4.2.js new file mode 100644 index 0000000000..b58263a0f2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/S7.8.5_A4.2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Two regular expression literals in a program evaluate to + regular expression objects that never compare as === to each other even + if the two literals' contents are identical +es5id: 7.8.5_A4.2 +description: Check equality two regular expression literals +---*/ + +var regexp1 = /(?:)/; +var regexp2 = /(?:)/; +assert.notSameValue( + regexp1, + regexp2, + "var regexp1 = /(?:)/; var regexp2 = /(?:)/; regexp1 !== regexp2" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/browser.js b/js/src/tests/test262/language/literals/regexp/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/browser.js diff --git a/js/src/tests/test262/language/literals/regexp/early-err-bad-flag.js b/js/src/tests/test262/language/literals/regexp/early-err-bad-flag.js new file mode 100644 index 0000000000..03b86899d4 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-bad-flag.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// 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-primary-expression-regular-expression-literals-static-semantics-early-errors +info: | + PrimaryExpression : RegularExpressionLiteral + +description: > + It is a Syntax Error if FlagText of RegularExpressionLiteral contains any code points other than "g", "i", "m", "u", or "y", ... + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/./G; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-dup-flag.js b/js/src/tests/test262/language/literals/regexp/early-err-dup-flag.js new file mode 100644 index 0000000000..d169db2de2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-dup-flag.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// 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-primary-expression-regular-expression-literals-static-semantics-early-errors +info: | + PrimaryExpression : RegularExpressionLiteral + +description: > + It is a Syntax Error if FlagText of RegularExpressionLiteral contains ... the same code point more than once. + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/./gig; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-flags-unicode-escape.js b/js/src/tests/test262/language/literals/regexp/early-err-flags-unicode-escape.js new file mode 100644 index 0000000000..618cc1685e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-flags-unicode-escape.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// 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-literals-regular-expression-literals-static-semantics-early-errors +info: | + RegularExpressionFlags :: + RegularExpressionFlags IdentifierPart + +description: > + It is a Syntax Error if IdentifierPart contains a Unicode escape sequence. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/./\u0067; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-pattern.js b/js/src/tests/test262/language/literals/regexp/early-err-pattern.js new file mode 100644 index 0000000000..52760381ae --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-pattern.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// 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-primary-expression-regular-expression-literals-static-semantics-early-errors +info: | + PrimaryExpression : RegularExpressionLiteral + +description: > + It is a Syntax Error if BodyText of RegularExpressionLiteral cannot be recognized using the goal symbol Pattern of the ECMAScript RegExp grammar specified in #sec-patterns. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/?/; diff --git a/js/src/tests/test262/language/literals/regexp/inequality.js b/js/src/tests/test262/language/literals/regexp/inequality.js new file mode 100644 index 0000000000..ab355e70a6 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/inequality.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Regular expression literals should not compare as equal even if they appear in the same source position. +esid: sec-regular-expression-literals-runtime-semantics-evaluation +---*/ + +function makeRegExp() { + return /(?:)/; +} + +assert.notSameValue(makeRegExp(), makeRegExp()); + +var values = []; +for (var i = 0; i < 2; ++i) { + values[i] = /(?:)/; +} + +assert.notSameValue(values[0], values[1]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-exact.js b/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-exact.js new file mode 100644 index 0000000000..af8c227ee9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-exact.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// 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 :: + SourceCharacter but 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/{2}/; diff --git a/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-lower.js b/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-lower.js new file mode 100644 index 0000000000..04c09bc675 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-lower.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// 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 :: + SourceCharacter but 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/{2,}/; diff --git a/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-range.js b/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-range.js new file mode 100644 index 0000000000..b7066f93f3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-braced-quantifier-range.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// 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 :: + SourceCharacter but 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/{2,3}/; diff --git a/js/src/tests/test262/language/literals/regexp/invalid-optional-lookbehind.js b/js/src/tests/test262/language/literals/regexp/invalid-optional-lookbehind.js new file mode 100644 index 0000000000..418769eb9f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-optional-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<=.)?/; diff --git a/js/src/tests/test262/language/literals/regexp/invalid-optional-negative-lookbehind.js b/js/src/tests/test262/language/literals/regexp/invalid-optional-negative-lookbehind.js new file mode 100644 index 0000000000..432227f13e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-optional-negative-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<!.)?/; diff --git a/js/src/tests/test262/language/literals/regexp/invalid-range-lookbehind.js b/js/src/tests/test262/language/literals/regexp/invalid-range-lookbehind.js new file mode 100644 index 0000000000..4877a59dc2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-range-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<=.){2,3}/; diff --git a/js/src/tests/test262/language/literals/regexp/invalid-range-negative-lookbehind.js b/js/src/tests/test262/language/literals/regexp/invalid-range-negative-lookbehind.js new file mode 100644 index 0000000000..355fe20d78 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/invalid-range-negative-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<!.){2,3}/; diff --git a/js/src/tests/test262/language/literals/regexp/lastIndex.js b/js/src/tests/test262/language/literals/regexp/lastIndex.js new file mode 100644 index 0000000000..2e9d03590a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/lastIndex.js @@ -0,0 +1,38 @@ +// 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-expression-literals-runtime-semantics-evaluation +description: Initial state of the `lastIndex` property +info: | + [...] + 3. Return RegExpCreate(pattern, flags). + + 21.2.3.2.3 Runtime Semantics: RegExpCreate + + 1. Let obj be ? RegExpAlloc(%RegExp%). + 2. Return ? RegExpInitialize(obj, P, F). + + 21.2.3.2.2 Runtime Semantics: RegExpInitialize + + [...] + 12. Perform ? Set(obj, "lastIndex", 0, true). + [...] + + 21.2.3.2.1 Runtime Semantics: RegExpAlloc + + [...] + 2. Perform ! DefinePropertyOrThrow(obj, "lastIndex", PropertyDescriptor + {[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}). + [...] +includes: [propertyHelper.js] +---*/ + +var re = /./; + +assert.sameValue(re.lastIndex, 0); + +verifyNotEnumerable(re, 'lastIndex'); +verifyWritable(re, 'lastIndex'); +verifyNotConfigurable(re, 'lastIndex'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/mongolian-vowel-separator-eval.js b/js/src/tests/test262/language/literals/regexp/mongolian-vowel-separator-eval.js new file mode 100644 index 0000000000..67f7efaaa8 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/mongolian-vowel-separator-eval.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-unicode-format-control-characters +description: > + Mongolian Vowel Separator can appear in regular expression literals (eval code). +info: | + 11.1 Unicode Format-Control Characters + + The Unicode format-control characters (i.e., the characters in category “Cf” + in the Unicode Character Database such as LEFT-TO-RIGHT MARK or RIGHT-TO-LEFT + MARK) are control codes used to control the formatting of a range of text in + the absence of higher-level protocols for this (such as mark-up languages). + + It is useful to allow format-control characters in source text to facilitate + editing and display. All format control characters may be used within comments, + and within string literals, template literals, and regular expression literals. +features: [u180e] +---*/ + +assert.sameValue(eval("/\u180E/").source, "\u180E"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/mongolian-vowel-separator.js b/js/src/tests/test262/language/literals/regexp/mongolian-vowel-separator.js new file mode 100644 index 0000000000..d34c22c09f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/mongolian-vowel-separator.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-unicode-format-control-characters +description: > + Mongolian Vowel Separator can appear in regular expression literals. +info: | + 11.1 Unicode Format-Control Characters + + The Unicode format-control characters (i.e., the characters in category “Cf” + in the Unicode Character Database such as LEFT-TO-RIGHT MARK or RIGHT-TO-LEFT + MARK) are control codes used to control the formatting of a range of text in + the absence of higher-level protocols for this (such as mark-up languages). + + It is useful to allow format-control characters in source text to facilitate + editing and display. All format control characters may be used within comments, + and within string literals, template literals, and regular expression literals. +features: [u180e] +---*/ + +// U+180E in regular expressions; UTF8(0x180E) = 0xE1 0xA0 0x8E +assert.sameValue(//.source, "\u180E"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/browser.js b/js/src/tests/test262/language/literals/regexp/named-groups/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/browser.js diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/forward-reference.js b/js/src/tests/test262/language/literals/regexp/named-groups/forward-reference.js new file mode 100644 index 0000000000..2f8588f751 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/forward-reference.js @@ -0,0 +1,12 @@ +// 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")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js new file mode 100644 index 0000000000..52c85bb005 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>a)\k<ab>/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-2.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-2.js new file mode 100644 index 0000000000..98acd42120 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-2.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>a)\k<ab>/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-3-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-3-u.js new file mode 100644 index 0000000000..ab2512d83e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-3-u.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<ab>a)\k<a>/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-3.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-3.js new file mode 100644 index 0000000000..9995ddaed8 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-3.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<ab>a)\k<a>/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-4-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-4-u.js new file mode 100644 index 0000000000..c2a97ae631 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-4-u.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a>(?<ab>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-4.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-4.js new file mode 100644 index 0000000000..f410a00797 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-4.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a>(?<ab>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-5.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-5.js new file mode 100644 index 0000000000..d42ee9e35c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-5.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a>(?<b>x)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-u.js new file mode 100644 index 0000000000..f30c4f8aa7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-u.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k<b>/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-without-group-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-without-group-u.js new file mode 100644 index 0000000000..3598f94426 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname-without-group-u.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a>/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname.js new file mode 100644 index 0000000000..ca192d22e1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-dangling-groupname.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k<b>/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2-u.js new file mode 100644 index 0000000000..5019ab119f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2-u.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupSpecifiers within one alternative must be unique. +info: | + It is a Syntax Error if |Pattern| contains two distinct |GroupSpecifier|s + _x_ and _y_ for which CapturingGroupName(_x_) is the same as + CapturingGroupName(_y_) and such that CanBothParticipate(_x_, _y_) is *true*. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +$DONOTEVALUATE(); + +/(?<a>a)(?<b>b)(?<a>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js new file mode 100644 index 0000000000..8ed19cedc5 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupSpecifiers within one alternative must be unique. +info: | + It is a Syntax Error if |Pattern| contains two distinct |GroupSpecifier|s + _x_ and _y_ for which CapturingGroupName(_x_) is the same as + CapturingGroupName(_y_) and such that CanBothParticipate(_x_, _y_) is *true*. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +$DONOTEVALUATE(); + +/(?<a>a)(?<b>b)(?<a>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-u.js new file mode 100644 index 0000000000..efc8218273 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-u.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupSpecifiers within one alternative must be unique. +info: | + It is a Syntax Error if |Pattern| contains two distinct |GroupSpecifier|s + _x_ and _y_ for which CapturingGroupName(_x_) is the same as + CapturingGroupName(_y_) and such that CanBothParticipate(_x_, _y_) is *true*. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +$DONOTEVALUATE(); + +/(?<a>a)(?<a>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js new file mode 100644 index 0000000000..628eb10a82 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: GroupSpecifiers within one alternative must be unique. +info: | + It is a Syntax Error if |Pattern| contains two distinct |GroupSpecifier|s + _x_ and _y_ for which CapturingGroupName(_x_) is the same as + CapturingGroupName(_y_) and such that CanBothParticipate(_x_, _y_) is *true*. +esid: sec-patterns-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +features: [regexp-named-groups] +---*/ + +$DONOTEVALUATE(); + +/(?<a>a)(?<a>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-empty-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-empty-groupspecifier-u.js new file mode 100644 index 0000000000..83a09b9956 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-empty-groupspecifier-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-empty-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-empty-groupspecifier.js new file mode 100644 index 0000000000..90f4ee1afb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-empty-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-identity-escape-in-capture-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-identity-escape-in-capture-u.js new file mode 100644 index 0000000000..0bb1f1327e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-identity-escape-in-capture-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>\a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-2-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-2-u.js new file mode 100644 index 0000000000..2eba873154 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-2-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k<a/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js new file mode 100644 index 0000000000..f100d3f1f3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k<a/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-3-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-3-u.js new file mode 100644 index 0000000000..c0a550e311 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-3-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k<>/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-3.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-3.js new file mode 100644 index 0000000000..261544e03f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-3.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k<>/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js new file mode 100644 index 0000000000..93d9a6a8fb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a(?<a>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js new file mode 100644 index 0000000000..9ae652fbfc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a(?<a>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js new file mode 100644 index 0000000000..2053830a01 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k(?<a>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-u.js new file mode 100644 index 0000000000..3a74d7d7e0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-2-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-2-u.js new file mode 100644 index 0000000000..21f0d481a8 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-2-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<>/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-3-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-3-u.js new file mode 100644 index 0000000000..0d5ddc0ca9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-3-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-u.js new file mode 100644 index 0000000000..717ee16c2a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/\k<a/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname.js new file mode 100644 index 0000000000..7487e008c1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-incomplete-groupname.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a>.)\k/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-lone-surrogate-groupname.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-lone-surrogate-groupname.js new file mode 100644 index 0000000000..c279b25900 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-lone-surrogate-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: Lone surrogates in RegExp group names +esid: prod-GroupSpecifier +features: [regexp-named-groups] +---*/ + +assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/"), "Lead"); +assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/"), "Trail"); +assert.throws(SyntaxError, () => eval("/(?<a\uD801>.)/u"), "Lead with u flag"); +assert.throws(SyntaxError, () => eval("/(?<a\uDCA4>.)/u"), "Trail with u flag"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4-u.js new file mode 100644 index 0000000000..d7bcc1770a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\>.)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4.js new file mode 100644 index 0000000000..4dfa419755 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier.js new file mode 100644 index 0000000000..38807e1c86 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<$❞>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2-u.js new file mode 100644 index 0000000000..230092e8ef --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<𐒤>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2.js new file mode 100644 index 0000000000..b25da28a84 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<𐒤>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-3.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-3.js new file mode 100644 index 0000000000..289bc4ca5c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-3.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\uD83D\uDF12>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4-u.js new file mode 100644 index 0000000000..0dacb1134d --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\uD801>.)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4.js new file mode 100644 index 0000000000..92e0e30821 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\uD801>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5-u.js new file mode 100644 index 0000000000..44249276ea --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\uDCA4>.)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5.js new file mode 100644 index 0000000000..90df2cc5b5 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\uDCA4>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-6.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-6.js new file mode 100644 index 0000000000..bb2f21ee55 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-6.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\u{1F08B}>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-7.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-7.js new file mode 100644 index 0000000000..8ebbc51ea1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-7.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\u{10FFFF}>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8-u.js new file mode 100644 index 0000000000..e2f9d21f68 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<\>.)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8.js new file mode 100644 index 0000000000..63777657b1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<\>.)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-9-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-9-u.js new file mode 100644 index 0000000000..4002519fd0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-9-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a\u{110000}>.)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-u.js new file mode 100644 index 0000000000..82cc67c825 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<❤>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier.js new file mode 100644 index 0000000000..3958b2d282 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<❤>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-numeric-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-numeric-groupspecifier-u.js new file mode 100644 index 0000000000..4f31018512 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-numeric-groupspecifier-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<42a>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-numeric-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-numeric-groupspecifier.js new file mode 100644 index 0000000000..19244144bc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-numeric-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<42a>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier-u.js new file mode 100644 index 0000000000..5128e74e8a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<:a>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier.js new file mode 100644 index 0000000000..e22331acdb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<:a>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier-u.js new file mode 100644 index 0000000000..b9d7fcba6c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a:>a)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier.js new file mode 100644 index 0000000000..08d11b25dc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<a:>a)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-unterminated-groupspecifier-u.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-unterminated-groupspecifier-u.js new file mode 100644 index 0000000000..fc8cfd4a8e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-unterminated-groupspecifier-u.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<aa)/u; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/invalid-unterminated-groupspecifier.js b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-unterminated-groupspecifier.js new file mode 100644 index 0000000000..e2c7bdb4fb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/invalid-unterminated-groupspecifier.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// 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] +---*/ + +$DONOTEVALUATE(); + +/(?<aa)/; diff --git a/js/src/tests/test262/language/literals/regexp/named-groups/shell.js b/js/src/tests/test262/language/literals/regexp/named-groups/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/named-groups/shell.js diff --git a/js/src/tests/test262/language/literals/regexp/regexp-first-char-no-line-separator.js b/js/src/tests/test262/language/literals/regexp/regexp-first-char-no-line-separator.js new file mode 100644 index 0000000000..b6222bb8b7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/regexp-first-char-no-line-separator.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <LS> +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/
/ + +/* +There is a <LS> between the two / characters +*/ diff --git a/js/src/tests/test262/language/literals/regexp/regexp-first-char-no-paragraph-separator.js b/js/src/tests/test262/language/literals/regexp/regexp-first-char-no-paragraph-separator.js new file mode 100644 index 0000000000..ef25939c6e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/regexp-first-char-no-paragraph-separator.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + The first character of a regular expression may not be a <PS> +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/
/ + +/* +There is a <PS> between the two / characters +*/ diff --git a/js/src/tests/test262/language/literals/regexp/regexp-source-char-no-line-separator.js b/js/src/tests/test262/language/literals/regexp/regexp-source-char-no-line-separator.js new file mode 100644 index 0000000000..2174c1ea73 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/regexp-source-char-no-line-separator.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionBackslashSequence +info: | + RegularExpressionBackslashSequence :: + \ RegularExpressionNonTerminator + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + + LineTerminator :: + <LF> + <CR> + <LS> + <PS> + +description: > + A regular expression may not contain a <LS> as a SourceCharacter +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a\\
/ + +/* +There is a <LS> between "a\\
" and "/" +*/ diff --git a/js/src/tests/test262/language/literals/regexp/regexp-source-char-no-paragraph-separator.js b/js/src/tests/test262/language/literals/regexp/regexp-source-char-no-paragraph-separator.js new file mode 100644 index 0000000000..13643f5206 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/regexp-source-char-no-paragraph-separator.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-RegularExpressionNonTerminator +info: | + RegularExpressionBody :: + RegularExpressionFirstChar RegularExpressionChars + + RegularExpressionChars :: + [empty] + RegularExpressionChars RegularExpressionChar + + RegularExpressionFirstChar :: + RegularExpressionNonTerminator but not one of * or \ or / or [ + + RegularExpressionNonTerminator :: + SourceCharacter but not LineTerminator + +description: > + A regular expression may not contain a <PS> as a SourceCharacter +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/a\\
/ + +/* +There is a <PS> between "a\\
" and "/" +*/ diff --git a/js/src/tests/test262/language/literals/regexp/shell.js b/js/src/tests/test262/language/literals/regexp/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/shell.js diff --git a/js/src/tests/test262/language/literals/regexp/u-astral-char-class-invert.js b/js/src/tests/test262/language/literals/regexp/u-astral-char-class-invert.js new file mode 100644 index 0000000000..17d8dddaaa --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-astral-char-class-invert.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atom +description: > + Literal astral symbols within inverted CharacterClass. +info: | + The production Atom :: CharacterClass evaluates as follows: + + 1. Evaluate CharacterClass to obtain a CharSet A and a Boolean invert. + 2. Call CharacterSetMatcher(A, invert, direction) and return its Matcher result. + + Runtime Semantics: CharacterSetMatcher ( A, invert, direction ) + + 1. Return an internal Matcher closure that takes two arguments, a State x and + a Continuation c, and performs the following steps: + [...] + f. Let cc be Canonicalize(ch). + g. If invert is false, then + [...] + h. Else, + i. Assert: invert is true. + ii. If there exists a member a of set A such that Canonicalize(a) is cc, + return failure. +---*/ + +assert.sameValue(/^[^❤️]$/u.exec("❤️"), null); +assert.sameValue(/^[^🧡]/u.exec("🧡"), null); +assert.sameValue(/[^💛]$/u.exec("💛"), null); +assert.sameValue(/[^💚]/u.exec("💚"), null); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-astral.js b/js/src/tests/test262/language/literals/regexp/u-astral.js new file mode 100644 index 0000000000..70ab2b3cc6 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-astral.js @@ -0,0 +1,57 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Literal astral symbols within a pattern +es6id: 21.2.2.8.2 +info: | + 21.2.2.2 Pattern + + The production Pattern :: Disjunction evaluates as follows: + + 1. Evaluate Disjunction to obtain a Matcher m. + 2. Return an internal closure that takes two arguments, a String str + and an integer index, and performs the following steps: + 1. If Unicode is true, let Input be a List consisting of the + sequence of code points of str interpreted as a UTF-16 encoded + (6.1.4) Unicode string. Otherwise, let Input be a List consisting + of the sequence of code units that are the elements of str. Input + will be used throughout the algorithms in 21.2.2. Each element of + Input is considered to be a character. +---*/ + +assert(/𝌆{2}/u.test('𝌆𝌆'), 'quantifier application'); + +assert(/^[𝌆]$/u.test('𝌆'), 'as a ClassAtom'); + +var rangeRe = /[💩-💫]/u; +assert.sameValue( + rangeRe.test('\ud83d\udca8'), + false, + 'ClassAtom as lower range boundary, input below (U+1F4A8)' +); +assert.sameValue( + rangeRe.test('\ud83d\udca9'), + true, + 'ClassAtom as lower range boundary, input match (U+1F4A9)' +); +assert.sameValue( + rangeRe.test('\ud83d\udcaa'), + true, + 'ClassAtom as upper- and lower-range boundary, input within (U+1F4AA)' +); +assert.sameValue( + rangeRe.test('\ud83d\udcab'), + true, + 'ClassAtom as upper range boundary, input match (U+1F4AB)' +); +assert.sameValue( + rangeRe.test('\ud83d\udcac'), + false, + 'ClassAtom as upper range boundary, input above (U+1F4AC)' +); + +assert(/[^𝌆]/u.test('\ud834'), 'Negated character classes (LeadSurrogate)'); +assert(/[^𝌆]/u.test('\udf06'), 'Negated character classes (TrailSurrogate)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-case-mapping.js b/js/src/tests/test262/language/literals/regexp/u-case-mapping.js new file mode 100644 index 0000000000..2ac4e2d64f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-case-mapping.js @@ -0,0 +1,51 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Case mapping of astral symbols +es6id: 21.2.2.8.2 +info: | + 21.2.2.8.2 Runtime Semantics: Canonicalize ( ch ) + + The abstract operation Canonicalize takes a character parameter ch and + performs the following steps: + + 1. If IgnoreCase is false, return ch. + 2. If Unicode is true, + a. If the file CaseFolding.txt of the Unicode Character Database + provides a simple or common case folding mapping for ch, return + the result of applying that mapping to ch. + b. Else, return ch. +---*/ + +assert.sameValue( + /\u212a/i.test('k'), + false, + 'Case mapping is not applied in the absence of the `u` flag' +); +assert.sameValue( + /\u212a/i.test('K'), + false, + 'Case mapping is not applied in the absence of the `u` flag' +); +assert.sameValue( + /\u212a/u.test('k'), + false, + 'Case mapping is not applied in the absence of the `i` flag' +); +assert.sameValue( + /\u212a/u.test('K'), + false, + 'Case mapping is not applied in the absence of the `i` flag' +); + +assert( + /\u212a/iu.test('k'), + 'Case mapping is applied in the presence of the `i` and `u` flags' +); +assert( + /\u212a/iu.test('K'), + 'Case mapping is applied in the presence of the `i` and `u` flags' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-class-escape.js b/js/src/tests/test262/language/literals/regexp/u-invalid-class-escape.js new file mode 100644 index 0000000000..fe11f66da5 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-class-escape.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\c0/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-extended-pattern-char.js b/js/src/tests/test262/language/literals/regexp/u-invalid-extended-pattern-char.js new file mode 100644 index 0000000000..bbcf0e2f3c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-extended-pattern-char.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/{/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-identity-escape.js b/js/src/tests/test262/language/literals/regexp/u-invalid-identity-escape.js new file mode 100644 index 0000000000..7adfd0245b --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-identity-escape.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\M/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-legacy-octal-escape.js b/js/src/tests/test262/language/literals/regexp/u-invalid-legacy-octal-escape.js new file mode 100644 index 0000000000..1d5ea2d650 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-legacy-octal-escape.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\1/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js new file mode 100644 index 0000000000..43fdc68c86 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/[\d-a]/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js new file mode 100644 index 0000000000..f340b0819c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/[\s-\d]/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js new file mode 100644 index 0000000000..1097c84184 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/[%-\d]/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges.js b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges.js new file mode 100644 index 0000000000..a334587895 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-non-empty-class-ranges.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/[--\d]/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-oob-decimal-escape.js b/js/src/tests/test262/language/literals/regexp/u-invalid-oob-decimal-escape.js new file mode 100644 index 0000000000..9e4723169f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-oob-decimal-escape.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\8/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-optional-lookahead.js b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-lookahead.js new file mode 100644 index 0000000000..7bf80effc7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-lookahead.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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: B.1.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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?=.)?/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-optional-lookbehind.js b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-lookbehind.js new file mode 100644 index 0000000000..0fa338f56a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<=.)?/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-optional-negative-lookahead.js b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-negative-lookahead.js new file mode 100644 index 0000000000..171ace8dac --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-negative-lookahead.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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: B.1.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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?!.)?/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-optional-negative-lookbehind.js b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-negative-lookbehind.js new file mode 100644 index 0000000000..85945989d3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-optional-negative-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<!.)?/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-range-lookahead.js b/js/src/tests/test262/language/literals/regexp/u-invalid-range-lookahead.js new file mode 100644 index 0000000000..fa1e69e9fb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-range-lookahead.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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: B.1.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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?=.){2,3}/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-range-lookbehind.js b/js/src/tests/test262/language/literals/regexp/u-invalid-range-lookbehind.js new file mode 100644 index 0000000000..b93fe8065c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-range-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<=.){2,3}/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-range-negative-lookahead.js b/js/src/tests/test262/language/literals/regexp/u-invalid-range-negative-lookahead.js new file mode 100644 index 0000000000..3dfbe2dc04 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-range-negative-lookahead.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// 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: B.1.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: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?!.){2,3}/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-invalid-range-negative-lookbehind.js b/js/src/tests/test262/language/literals/regexp/u-invalid-range-negative-lookbehind.js new file mode 100644 index 0000000000..ac8519c517 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-invalid-range-negative-lookbehind.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Igalia S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +description: Lookbehinds are not treated as a QuantifiableAssertion +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion[N]:: + ( ? = Disjunction[~U, ?N] ) + ( ? ! Disjunction[~U, ?N] ) +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/.(?<!.){2,3}/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-null-character-escape.js b/js/src/tests/test262/language/literals/regexp/u-null-character-escape.js new file mode 100644 index 0000000000..4abd046000 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-null-character-escape.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-CharacterEscape +description: > + Null character escape is permitted in Unicode patterns. +info: | + CharacterEscape[U] :: + ControlEscape + c ControlLetter + 0 [lookahead ∉ DecimalDigit] + HexEscapeSequence + RegExpUnicodeEscapeSequence[?U] + IdentityEscape[?U] + + DecimalDigit :: one of + 0 1 2 3 4 5 6 7 8 9 +---*/ + +var nullChar = String.fromCharCode(0); +assert.sameValue(/\0/u.exec(nullChar)[0], nullChar); +assert(/^\0a$/u.test('\0a')); +assert.sameValue('\x00②'.match(/\0②/u)[0], '\x00②'); +assert.sameValue('\u0000፬'.search(/\0፬$/u), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-char-class.js b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-char-class.js new file mode 100644 index 0000000000..b89f509f96 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-char-class.js @@ -0,0 +1,35 @@ +// 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-atom +es6id: 21.2.2.8 +description: > + Support for surrogate pairs within patterns match by the CharacterClass Atom +info: | + The production Atom :: CharacterClass evaluates as follows: + + 1. Evaluate CharacterClass to obtain a CharSet A and a Boolean invert. + 2. Call CharacterSetMatcher(A, invert) and return its Matcher result. + + Runtime Semantics: CharacterSetMatcher Abstract Operation + + 1. Return an internal Matcher closure that takes two arguments, a State x and + a Continuation c, and performs the following steps when evaluated: + [...] + d. Let cc be Canonicalize(ch). + [...] +---*/ + +assert(/^[\ud800\udc00]$/u.test('\ud800\udc00')); +assert.sameValue( + /[\ud800\udc00]/u.test('\ud800'), + false, + '\\ud800 does not qualify as a class member' +); +assert.sameValue( + /[\ud800\udc00]/u.test('\udc00'), + false, + '\\udc00 does not qualify as a class member' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-dot.js b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-dot.js new file mode 100644 index 0000000000..ae415ce0ee --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-dot.js @@ -0,0 +1,25 @@ +// 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-atom +es6id: 21.2.2.8 +description: > + Support for surrogate pairs within patterns match by the "period" Atom +info: | + The production Atom :: . evaluates as follows: + + 1. Let A be the set of all characters except LineTerminator. + 2. Call CharacterSetMatcher(A, false) and return its Matcher result. + + Runtime Semantics: CharacterSetMatcher Abstract Operation + + 1. Return an internal Matcher closure that takes two arguments, a State x and + a Continuation c, and performs the following steps when evaluated: + [...] + d. Let cc be Canonicalize(ch). + [...] +---*/ + +assert(/^.$/u.test('\ud800\udc00')); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-escape-char-class.js b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-escape-char-class.js new file mode 100644 index 0000000000..a061e90da0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-escape-char-class.js @@ -0,0 +1,26 @@ +// 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-atomescape +es6id: 21.2.2.9 +description: > + Support for surrogate pairs within patterns match by the CharacterClassEscape + AtomEscape +info: | + The production AtomEscape :: CharacterClassEscape evaluates as follows: + + 1. Evaluate CharacterClassEscape to obtain a CharSet A. + 2. Call CharacterSetMatcher(A, false) and return its Matcher result. + + Runtime Semantics: CharacterSetMatcher Abstract Operation + + 1. Return an internal Matcher closure that takes two arguments, a State x and + a Continuation c, and performs the following steps when evaluated: + [...] + d. Let cc be Canonicalize(ch). + [...] +---*/ + +assert(/^\S$/u.test('\ud800\udc00')); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-escape-decimal.js b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-escape-decimal.js new file mode 100644 index 0000000000..dd45a39d0e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs-atom-escape-decimal.js @@ -0,0 +1,31 @@ +// 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-atomescape +es6id: 21.2.2.9 +description: > + Support for surrogate pairs within patterns match by the DecimalEscape + AtomEscape +info: | + The production AtomEscape :: DecimalEscape evaluates as follows: + + [...] + 3. Return an internal Matcher closure that takes two arguments, a State x and + a Continuation c, and performs the following steps: + [...] + h. If there exists an integer i between 0 (inclusive) and len (exclusive) + such that Canonicalize(s[i]) is not the same character value as + Canonicalize(Input[e+i]), return failure. + + Runtime Semantics: CharacterSetMatcher Abstract Operation + + 1. Return an internal Matcher closure that takes two arguments, a State x and + a Continuation c, and performs the following steps when evaluated: + [...] + d. Let cc be Canonicalize(ch). + [...] +---*/ + +assert.sameValue(/(.+).*\1/u.test('\ud800\udc00\ud800'), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs.js b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs.js new file mode 100644 index 0000000000..ae24eab16e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-surrogate-pairs.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Out-of-range value of hexadecimal digits in UnicodeEscapeSequence +es6id: 21.2.2.10 +info: | + 21.2.2.10 CharacterEscape + + The production RegExpUnicodeEscapeSequence :: u LeadSurrogate \u + TrailSurrogate evaluates as follows: + + 1. Let lead be the result of evaluating LeadSurrogate. + 2. Let trail be the result of evaluating TrailSurrogate. + 3. Let cp be UTF16Decode(lead, trail). + 4. Return the character whose character value is cp. +---*/ + +assert(/^[\ud834\udf06]$/u.test('\ud834\udf06')); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/u-unicode-esc-bounds.js b/js/src/tests/test262/language/literals/regexp/u-unicode-esc-bounds.js new file mode 100644 index 0000000000..72e5190381 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-unicode-esc-bounds.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Out-of-range value of hexadecimal digits in UnicodeEscapeSequence +es6id: 21.2.1.1 +info: | + 21.2.1.1 Static Semantics: Early Errors + + RegExpUnicodeEscapeSequence :: u{ HexDigits } + + - It is a Syntax Error if the MV of HexDigits > 1114111. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\u{110000}/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-unicode-esc-non-hex.js b/js/src/tests/test262/language/literals/regexp/u-unicode-esc-non-hex.js new file mode 100644 index 0000000000..8043548ae5 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-unicode-esc-non-hex.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Non-hexadecimal value within the delimiters of a UnicodeEscapeSequence +es6id: 21.2.1 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\u{1,}/u; diff --git a/js/src/tests/test262/language/literals/regexp/u-unicode-esc.js b/js/src/tests/test262/language/literals/regexp/u-unicode-esc.js new file mode 100644 index 0000000000..59844d5639 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/u-unicode-esc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Unicode escape interpreted as the Mathematical Value of HexDigits +es6id: 21.2.2.10 +info: | + 21.2.2.10 CharacterEscape + + The production RegExpUnicodeEscapeSequence :: u{ HexDigits } evaluates as + follows: + + 1. Return the character whose code is the MV of HexDigits. +---*/ + +assert(/\u{0}/u.test('\u0000'), 'Minimum value (U+0000)'); +assert(/\u{1}/u.test('\u0001'), 'U+0001'); +assert.sameValue(/\u{1}/u.test('u'), false); +assert(/\u{3f}/u.test('?')); +assert(/\u{000000003f}/u.test('?'), 'Leading zeros'); +assert(/\u{3F}/u.test('?'), 'Case insensitivity'); +assert(/\u{10ffff}/u.test('\udbff\udfff'), 'Maxiumum value (U+10ffff)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/unicode-escape-nls-err.js b/js/src/tests/test262/language/literals/regexp/unicode-escape-nls-err.js new file mode 100644 index 0000000000..2e218a43c6 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/unicode-escape-nls-err.js @@ -0,0 +1,74 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-Pattern +description: NumericLiteralSeperator disallowed in unicode CodePoint sequence +info: | + Pattern[U, N]:: + Disjunction[?U, ?N] + + Disjunction[U, N]:: + Alternative[?U, ?N] + Alternative[?U, ?N]|Disjunction[?U, ?N] + + Alternative[U, N]:: + [empty] + Alternative[?U, ?N]Term[?U, ?N] + + Term[U, N]:: + Assertion[?U, ?N] + Atom[?U, ?N] + Atom[?U, ?N]Quantifier + + Atom[U, N]:: + PatternCharacter + . + \AtomEscape[?U, ?N] + CharacterClass[?U] + (GroupSpecifier[?U]Disjunction[?U, ?N]) + (?:Disjunction[?U, ?N]) + + AtomEscape[U, N]:: + DecimalEscape + CharacterClassEscape[?U] + CharacterEscape[?U] + [+N]kGroupName[?U] + + CharacterEscape[U]:: + ControlEscape + cControlLetter + 0[lookahead ∉ DecimalDigit] + HexEscapeSequence + RegExpUnicodeEscapeSequence[?U] + IdentityEscape[?U] + + RegExpUnicodeEscapeSequence[U]:: + [+U]uLeadSurrogate\uTrailSurrogate + [+U]uLeadSurrogate + [+U]uTrailSurrogate + [+U]uNonSurrogate + [~U]uHex4Digits + [+U]u{CodePoint} + + CodePoint :: + HexDigit but only if MV of HexDigits ≤ 0x10FFFF + CodePointDigits but only if MV of HexDigits ≤ 0x10FFFF + + CodePointDigits :: + HexDigit + CodePointDigitsHexDigit + + HexDigit :: one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F + +features: [numeric-separator-literal] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/\u{1F_639}/u; diff --git a/js/src/tests/test262/language/literals/regexp/y-assertion-start.js b/js/src/tests/test262/language/literals/regexp/y-assertion-start.js new file mode 100644 index 0000000000..9f7288af9f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/y-assertion-start.js @@ -0,0 +1,48 @@ +// 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-assertion +es6id: 21.2.2.6 +description: The `y` flag has no effect on the `^` assertion +info: | + Even when the y flag is used with a pattern, ^ always matches only at the + beginning of Input, or (if Multiline is true) at the beginning of a line. +---*/ + +var re; + +re = /^a/y; + +re.lastIndex = 0; +assert.sameValue( + re.test('a'), true, 'positive: beginning of input (without `m`)' +); + +re.lastIndex = 1; +assert.sameValue( + re.test(' a'), false, 'negative: within a line (without `m`)' +); + +re.lastIndex = 1; +assert.sameValue( + re.test('\na'), false, 'negative: beginning of line (without `m`)' +); + +re = /^a/my; + +re.lastIndex = 0; +assert.sameValue( + re.test('a'), true, 'positive: beginning of input (with `m`)' +); + +re.lastIndex = 1; +assert.sameValue( + re.test(' a'), false, 'negative: within a line (with `m`)' +); + +re.lastIndex = 1; +assert.sameValue( + re.test('\na'), true, 'positive: beginning of line (with `m`)' +); + +reportCompare(0, 0); |