diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/annexB/language/literals | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/annexB/language/literals')
12 files changed, 449 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/literals/browser.js b/js/src/tests/test262/annexB/language/literals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/browser.js diff --git a/js/src/tests/test262/annexB/language/literals/regexp/browser.js b/js/src/tests/test262/annexB/language/literals/regexp/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/browser.js diff --git a/js/src/tests/test262/annexB/language/literals/regexp/class-escape.js b/js/src/tests/test262/annexB/language/literals/regexp/class-escape.js new file mode 100644 index 0000000000..dc83ac701e --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/class-escape.js @@ -0,0 +1,72 @@ +// 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: Extensions to ClassEscape +info: | + ClassEscape[U] :: + b + [+U] - + [~U] c ClassControlLetter + CharacterClassEscape + CharacterEscape[?U] + + ClassControlLetter :: + DecimalDigit + _ + + The production ClassEscape :: c ClassControlLetter evaluates as follows: + + 1. Let ch be the character matched by ClassControlLetter. + 2. Let i be ch's character value. + 3. Let j be the remainder of dividing i by 32. + 4. Let d be the character whose character value is j. + 5. Return the CharSet containing the single character d. +---*/ + +var match; + +match = /\c0/.exec('\x0f\x10\x11'); +assert.sameValue(match, null, '\\c0 outside of CharacterClass'); + +match = /[\c0]/.exec('\x0f\x10\x11'); +assert.sameValue(match[0], '\x10', '\\c0 within CharacterClass'); + +match = /[\c00]+/.exec('\x0f0\x10\x11'); +assert.sameValue(match[0], '0\x10', '\\c00 within CharacterClass'); + +match = /\c1/.exec('\x10\x11\x12'); +assert.sameValue(match, null, '\\c1 outside of CharacterClass'); + +match = /[\c1]/.exec('\x10\x11\x12'); +assert.sameValue(match[0], '\x11', '\\c1 within CharacterClass'); + +match = /[\c10]+/.exec('\x100\x11\x12'); +assert.sameValue(match[0], '0\x11', '\\c10 within CharacterClass'); + +match = /\c8/.exec('\x17\x18\x19'); +assert.sameValue(match, null, '\\c8 outside of CharacterClass'); + +match = /[\c8]/.exec('\x17\x18\x19'); +assert.sameValue(match[0], '\x18', '\\c8 within CharacterClass'); + +match = /[\c80]+/.exec('\x170\x18\x19'); +assert.sameValue(match[0], '0\x18', '\\c80 within CharacterClass'); + +match = /\c9/.exec('\x18\x19\x1a'); +assert.sameValue(match, null, '\\c9 outside of CharacterClass'); + +match = /[\c9]/.exec('\x18\x19\x1a'); +assert.sameValue(match[0], '\x19', '\\c9 within CharacterClass'); + +match = /[\c90]+/.exec('\x180\x19\x1a'); +assert.sameValue(match[0], '0\x19', '\\c90 within CharacterClass'); + +match = /\c_/.exec('\x1e\x1f\x20'); +assert.sameValue(match, null, '\\c_ outside of CharacterClass'); + +match = /[\c_]/.exec('\x1e\x1f\x20'); +assert.sameValue(match[0], '\x1f', '\\c_ within CharacterClass'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/extended-pattern-char.js b/js/src/tests/test262/annexB/language/literals/regexp/extended-pattern-char.js new file mode 100644 index 0000000000..0624df6850 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/extended-pattern-char.js @@ -0,0 +1,32 @@ +// 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: Extended Pattern Characters (as distinct from Pattern Characters) +info: | + ExtendedPatternCharacter :: + SourceCharacterbut not one of ^$.*+?()[| + + The production ExtendedAtom::ExtendedPatternCharacter evaluates as follows: + + 1. Let ch be the character represented by ExtendedPatternCharacter. + 2. Let A be a one-element CharSet containing the character ch. + 3. Call CharacterSetMatcher(A, false) and return its Matcher result. +---*/ + +var match; + +match = /]/.exec(' ]{}'); +assert.sameValue(match[0], ']'); + +match = /{/.exec(' ]{}'); +assert.sameValue(match[0], '{'); + +match = /}/.exec(' ]{}'); +assert.sameValue(match[0], '}'); + +match = /x{o}x/.exec('x{o}x'); +assert.sameValue(match[0], 'x{o}x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/identity-escape.js b/js/src/tests/test262/annexB/language/literals/regexp/identity-escape.js new file mode 100644 index 0000000000..b1c3a53bee --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/identity-escape.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-regular-expressions-patterns +es6id: B.1.4 +description: Support for UnicodeIDContinue in IdentityEscape +info: | + IdentityEscape[U] :: + [+U] SyntaxCharacter + [+U] / + [~U] SourceCharacter but not c +---*/ + +var match; + +match = /\C/.exec('ABCDE'); +assert.sameValue(match[0], 'C'); + +match = /O\PQ/.exec('MNOPQRS'); +assert.sameValue(match[0], 'OPQ'); + +match = /\8/.exec('789'); +assert.sameValue(match[0], '8'); + +match = /7\89/.exec('67890'); +assert.sameValue(match[0], '789'); + +match = /\9/.exec('890'); +assert.sameValue(match[0], '9'); + +match = /8\90/.exec('78900'); +assert.sameValue(match[0], '890'); + +match = /(.)(.)(.)(.)(.)(.)(.)(.)\8\8/.exec('0123456777'); +assert.sameValue( + match[0], + '0123456777', + 'DecimalEscape takes precedence over IdentityEscape (\\8)' +); + +match = /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9\9/.exec('01234567888'); +assert.sameValue( + match[0], + '01234567888', + 'DecimalEscape takes precedence over IdentityEscape (\\9)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/legacy-octal-escape.js b/js/src/tests/test262/annexB/language/literals/regexp/legacy-octal-escape.js new file mode 100644 index 0000000000..6bba0756c3 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/legacy-octal-escape.js @@ -0,0 +1,72 @@ +// 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 +description: Legacy Octal Escape Sequence +info: | + CharacterEscape[U] :: + ControlEscape + c ControlLetter + 0 [lookahead ∉ DecimalDigit] + HexEscapeSequence + RegExpUnicodeEscapeSequence[?U] + [~U] LegacyOctalEscapeSequence + IdentityEscape[?U] + + LegacyOctalEscapeSequence :: + OctalDigit [lookahead ∉ OctalDigit] + ZeroToThree OctalDigit [lookahead ∉ OctalDigit] + FourToSeven OctalDigit + ZeroToThree OctalDigit OctalDigit + + The production CharacterEscape :: LegacyOctalEscapeSequence evaluates by + evaluating the SV of the LegacyOctalEscapeSequence and returning its + character result. +---*/ + +assert.sameValue(/\1/.exec('\x01')[0], '\x01', '\\1'); +assert.sameValue(/\2/.exec('\x02')[0], '\x02', '\\2'); +assert.sameValue(/\3/.exec('\x03')[0], '\x03', '\\3'); +assert.sameValue(/\4/.exec('\x04')[0], '\x04', '\\4'); +assert.sameValue(/\5/.exec('\x05')[0], '\x05', '\\5'); +assert.sameValue(/\6/.exec('\x06')[0], '\x06', '\\6'); +assert.sameValue(/\7/.exec('\x07')[0], '\x07', '\\7'); + +assert.sameValue(/\00/.exec('\x00')[0], '\x00', '\\00'); +assert.sameValue(/\07/.exec('\x07')[0], '\x07', '\\07'); + +assert.sameValue(/\30/.exec('\x18')[0], '\x18', '\\30'); +assert.sameValue(/\37/.exec('\x1f')[0], '\x1f', '\\37'); + +assert.sameValue(/\40/.exec('\x20')[0], '\x20', '\\40'); +assert.sameValue(/\47/.exec('\x27')[0], '\x27', '\\47'); + +assert.sameValue(/\70/.exec('\x38')[0], '\x38', '\\70'); +assert.sameValue(/\77/.exec('\x3f')[0], '\x3f', '\\77'); + +// Sequence is bounded according to the String Value +assert.sameValue(/\400/.exec('\x200')[0], '\x200', '\\400'); +assert.sameValue(/\470/.exec('\x270')[0], '\x270', '\\470'); +assert.sameValue(/\700/.exec('\x380')[0], '\x380', '\\700'); +assert.sameValue(/\770/.exec('\x3f0')[0], '\x3f0', '\\770'); + +assert.sameValue(/\000/.exec('\x00')[0], '\x00', '\\000'); +assert.sameValue(/\007/.exec('\x07')[0], '\x07', '\\007'); +assert.sameValue(/\070/.exec('\x38')[0], '\x38', '\\070'); + +assert.sameValue(/\300/.exec('\xc0')[0], '\xc0', '\\300'); +assert.sameValue(/\307/.exec('\xc7')[0], '\xc7', '\\307'); +assert.sameValue(/\370/.exec('\xf8')[0], '\xf8', '\\370'); +assert.sameValue(/\377/.exec('\xff')[0], '\xff', '\\377'); + +// Sequence is 3 characters max, including leading zeros +assert.sameValue(/\0111/.exec('\x091')[0], '\x091', '\\0111'); +assert.sameValue(/\0022/.exec('\x022')[0], '\x022', '\\0022'); +assert.sameValue(/\0003/.exec('\x003')[0], '\x003', '\\0003'); + +var match = /(.)\1/.exec('a\x01 aa'); +assert.sameValue( + match[0], 'aa', 'DecimalEscape takes precedence over LegacyOctalEscapeSequence' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/non-empty-class-ranges-no-dash.js b/js/src/tests/test262/annexB/language/literals/regexp/non-empty-class-ranges-no-dash.js new file mode 100644 index 0000000000..2d0984290e --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/non-empty-class-ranges-no-dash.js @@ -0,0 +1,49 @@ +// 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: Extensions to NonemptyClassRangesNoDash production +info: | + The production + NonemptyClassRangesNoDash::ClassAtomNoDash-ClassAtomClassRanges evaluates + as follows: + + 1. Evaluate ClassAtomNoDash to obtain a CharSet A. + 2. Evaluate ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRangeOrUnion(A, B) and let D be the resulting CharSet. + 5. Return the union of CharSets D and C. + + B.1.4.1.1 Runtime Semantics: CharacterRangeOrUnion Abstract Operation + + 1. If Unicode is false, then + a. If A does not contain exactly one character or B does not contain + exactly one character, then + i. Let C be the CharSet containing the single character - U+002D + (HYPHEN-MINUS). + ii. Return the union of CharSets A, B and C. + 2. Return CharacterRange(A, B). +---*/ + +var match; + +match = /[\d-a]+/.exec(':a0123456789-:'); +assert.sameValue(match[0], 'a0123456789-'); + +match = /[\d-az]+/.exec(':a0123456789z-:'); +assert.sameValue(match[0], 'a0123456789z-'); + +match = /[%-\d]+/.exec('&%0123456789-&'); +assert.sameValue(match[0], '%0123456789-'); + +match = /[%-\dz]+/.exec('&%0123456789z-&'); +assert.sameValue(match[0], '%0123456789z-'); + +match = /[\s-\d]+/.exec('& \t0123456789-&'); +assert.sameValue(match[0], ' \t0123456789-'); + +match = /[\s-\dz]+/.exec('& \t0123456789z-&'); +assert.sameValue(match[0], ' \t0123456789z-'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/non-empty-class-ranges.js b/js/src/tests/test262/annexB/language/literals/regexp/non-empty-class-ranges.js new file mode 100644 index 0000000000..7aad0745ee --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/non-empty-class-ranges.js @@ -0,0 +1,36 @@ +// 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: Extensions to NonemptyClassRanges production +info: | + The production NonemptyClassRanges :: ClassAtom-ClassAtom ClassRanges + evaluates as follows: + + 1. Evaluate the first ClassAtom to obtain a CharSet A. + 2. Evaluate the second ClassAtom to obtain a CharSet B. + 3. Evaluate ClassRanges to obtain a CharSet C. + 4. Call CharacterRangeOrUnion(A, B) and let D be the resulting CharSet. + 5. Return the union of CharSets D and C. + + B.1.4.1.1 Runtime Semantics: CharacterRangeOrUnion Abstract Operation + + 1. If Unicode is false, then + a. If A does not contain exactly one character or B does not contain + exactly one character, then + i. Let C be the CharSet containing the single character - U+002D + (HYPHEN-MINUS). + ii. Return the union of CharSets A, B and C. + 2. Return CharacterRange(A, B). +---*/ + +var match; + +match = /[--\d]+/.exec('.-0123456789-.'); +assert.sameValue(match[0], '-0123456789-'); + +match = /[--\dz]+/.exec('.-0123456789z-.'); +assert.sameValue(match[0], '-0123456789z-'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js b/js/src/tests/test262/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js new file mode 100644 index 0000000000..4e09b24a95 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B.1.4 +description: Quantifiable assertions `?=` ("followed by") +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion :: + ( ?= Disjunction ) + ( ?! Disjunction ) + + The production Term::QuantifiableAssertionQuantifier evaluates the same as + the production Term::AtomQuantifier but with QuantifiableAssertion + substituted for Atom. + + The production Assertion::QuantifiableAssertion evaluates by evaluating + QuantifiableAssertion to obtain a Matcher and returning that Matcher. + + Assertion (21.2.2.6) evaluation rules for the Assertion::(?=Disjunction) + and Assertion::(?!Disjunction) productions are also used for the + QuantifiableAssertion productions, but with QuantifiableAssertion + substituted for Assertion. +---*/ + +var match; + +match = /.(?=Z)*/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: *'); + +match = /.(?=Z)+/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: +'); + +match = /.(?=Z)?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: ?'); + +match = /.(?=Z){2}/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits }'); + +match = /.(?=Z){2,}/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits , }'); + +match = /.(?=Z){2,3}/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue( + match[0], 'b', 'quantifier: { DecimalDigits , DecimalDigits }' +); + +match = /.(?=Z)*?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: * ?'); + +match = /.(?=Z)+?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: + ?'); + +match = /.(?=Z)??/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'a', 'quantifier: ? ?'); + +match = /.(?=Z){2}?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits } ?'); + +match = /.(?=Z){2,}?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits , } ?'); + +match = /.(?=Z){2,3}?/.exec('a bZ cZZ dZZZ eZZZZ'); +assert.sameValue( + match[0], 'b', 'quantifier: { DecimalDigits , DecimalDigits } ?' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/quantifiable-assertion-not-followed-by.js b/js/src/tests/test262/annexB/language/literals/regexp/quantifiable-assertion-not-followed-by.js new file mode 100644 index 0000000000..2b92affa3a --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/quantifiable-assertion-not-followed-by.js @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expressions-patterns +es6id: B.1.4 +description: Quantifiable assertions `?!` ("not followed by") +info: | + Term[U] :: + [~U] QuantifiableAssertion Quantifier + + QuantifiableAssertion:: + ( ?= Disjunction ) + ( ?! Disjunction ) + + The production Term::QuantifiableAssertionQuantifier evaluates the same as + the production Term::AtomQuantifier but with QuantifiableAssertion + substituted for Atom. + + The production Assertion::QuantifiableAssertion evaluates by evaluating + QuantifiableAssertion to obtain a Matcher and returning that Matcher. + + Assertion (21.2.2.6) evaluation rules for the Assertion::(?=Disjunction) + and Assertion::(?!Disjunction) productions are also used for the + QuantifiableAssertion productions, but with QuantifiableAssertion + substituted for Assertion. +---*/ + +var match; + +match = /[a-e](?!Z)*/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: *'); + +match = /[a-e](?!Z)+/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: +'); + +match = /[a-e](?!Z)?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: ?'); + +match = /[a-e](?!Z){2}/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits }'); + +match = /[a-e](?!Z){2,}/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits , }'); + +match = /[a-e](?!Z){2,3}/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue( + match[0], 'e', 'quantifier: { DecimalDigits , DecimalDigits }' +); + +match = /[a-e](?!Z)*?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: * ?'); + +match = /[a-e](?!Z)+?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: + ?'); + +match = /[a-e](?!Z)??/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'a', 'quantifier: ? ?'); + +match = /[a-e](?!Z){2}?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits } ?'); + +match = /[a-e](?!Z){2,}?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue(match[0], 'e', 'quantifier: { DecimalDigits , } ?'); + +match = /[a-e](?!Z){2,3}?/.exec('aZZZZ bZZZ cZZ dZ e'); +assert.sameValue( + match[0], 'e', 'quantifier: { DecimalDigits , DecimalDigits } ?' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/literals/regexp/shell.js b/js/src/tests/test262/annexB/language/literals/regexp/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/regexp/shell.js diff --git a/js/src/tests/test262/annexB/language/literals/shell.js b/js/src/tests/test262/annexB/language/literals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/literals/shell.js |