From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../built-ins/RegExp/lookBehind/alternations.js | 29 ++++++++++++++ .../lookBehind/back-references-to-captures.js | 31 +++++++++++++++ .../built-ins/RegExp/lookBehind/back-references.js | 45 ++++++++++++++++++++++ .../test262/built-ins/RegExp/lookBehind/browser.js | 0 .../RegExp/lookBehind/captures-negative.js | 27 +++++++++++++ .../built-ins/RegExp/lookBehind/captures.js | 36 +++++++++++++++++ .../RegExp/lookBehind/do-not-backtrack.js | 27 +++++++++++++ .../built-ins/RegExp/lookBehind/greedy-loop.js | 28 ++++++++++++++ .../test262/built-ins/RegExp/lookBehind/misc.js | 39 +++++++++++++++++++ .../RegExp/lookBehind/mutual-recursive.js | 29 ++++++++++++++ .../built-ins/RegExp/lookBehind/negative.js | 34 ++++++++++++++++ .../RegExp/lookBehind/nested-lookaround.js | 31 +++++++++++++++ .../test262/built-ins/RegExp/lookBehind/shell.js | 0 .../RegExp/lookBehind/simple-fixed-length.js | 42 ++++++++++++++++++++ .../built-ins/RegExp/lookBehind/sliced-strings.js | 22 +++++++++++ .../built-ins/RegExp/lookBehind/start-of-line.js | 43 +++++++++++++++++++++ .../test262/built-ins/RegExp/lookBehind/sticky.js | 32 +++++++++++++++ .../built-ins/RegExp/lookBehind/variable-length.js | 27 +++++++++++++ .../built-ins/RegExp/lookBehind/word-boundary.js | 30 +++++++++++++++ 19 files changed, 552 insertions(+) create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/alternations.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/back-references-to-captures.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/back-references.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/browser.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/captures-negative.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/captures.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/do-not-backtrack.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/greedy-loop.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/misc.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/mutual-recursive.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/negative.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/nested-lookaround.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/shell.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/simple-fixed-length.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/sliced-strings.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/start-of-line.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/sticky.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/variable-length.js create mode 100644 js/src/tests/test262/built-ins/RegExp/lookBehind/word-boundary.js (limited to 'js/src/tests/test262/built-ins/RegExp/lookBehind') diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/alternations.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/alternations.js new file mode 100644 index 0000000000..64c4247043 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/alternations.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: Alternations are tried left to right, and we do not backtrack into a lookbehind. +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +assert.compareArray("xabcd".match(/.*(?<=(..|...|....))(.*)/), ["xabcd", "cd", ""], "#1"); +assert.compareArray("xabcd".match(/.*(?<=(xx|...|....))(.*)/), ["xabcd", "bcd", ""], "#2"); +assert.compareArray("xxabcd".match(/.*(?<=(xx|...))(.*)/), ["xxabcd", "bcd", ""], "#3"); +assert.compareArray("xxabcd".match(/.*(?<=(xx|xxx))(.*)/), ["xxabcd", "xx", "abcd"], "#4"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/back-references-to-captures.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/back-references-to-captures.js new file mode 100644 index 0000000000..0f1f853ecc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/back-references-to-captures.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: Back references to captures inside the lookbehind. +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +assert.compareArray("abcCd".match(/(?<=\1(\w))d/i), ["d", "C"], "#1"); +assert.compareArray("abxxd".match(/(?<=\1([abx]))d/), ["d", "x"], "#2"); +assert.compareArray("ababc".match(/(?<=\1(\w+))c/), ["c", "ab"], "#3"); +assert.compareArray("ababbc".match(/(?<=\1(\w+))c/), ["c", "b"], "#4"); +assert.sameValue("ababdc".match(/(?<=\1(\w+))c/), null, "#5"); +assert.compareArray("ababc".match(/(?<=(\w+)\1)c/), ["c", "abab"], "#6"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/back-references.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/back-references.js new file mode 100644 index 0000000000..f6a3f7c842 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/back-references.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: Back references +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +assert.compareArray("abb".match(/(.)(?<=(\1\1))/), ["b", "b", "bb"], "#1"); +assert.compareArray("abB".match(/(.)(?<=(\1\1))/i), ["B", "B", "bB"], "#2"); +assert.compareArray("aabAaBa".match(/((\w)\w)(?<=\1\2\1)/i), ["aB", "aB", "a"], "#3"); +assert.compareArray("aabAaBa".match(/(\w(\w))(?<=\1\2\1)/i), ["Ba", "Ba", "a"], "#4"); +assert.compareArray("abaBbAa".match(/(?=(\w))(?<=(\1))./i), ["b", "b", "B"], "#5"); +assert.compareArray(" 'foo' ".match(/(?<=(.))(\w+)(?=\1)/), ["foo", "'", "foo"], "#6"); +assert.compareArray(" \"foo\" ".match(/(?<=(.))(\w+)(?=\1)/), ["foo", "\"", "foo"], "#7"); +assert.compareArray("abbb".match(/(.)(?<=\1\1\1)/), ["b", "b"], "#8"); +assert.compareArray("fababab".match(/(..)(?<=\1\1\1)/), ["ab", "ab"], "#9"); + +assert.sameValue(" .foo\" ".match(/(?<=(.))(\w+)(?=\1)/), null, "#10"); +assert.sameValue("ab".match(/(.)(?<=\1\1\1)/), null, "#11"); +assert.sameValue("abb".match(/(.)(?<=\1\1\1)/), null, "#12"); +assert.sameValue("ab".match(/(..)(?<=\1\1\1)/), null, "#13"); +assert.sameValue("abb".match(/(..)(?<=\1\1\1)/), null, "#14"); +assert.sameValue("aabb".match(/(..)(?<=\1\1\1)/), null, "#15"); +assert.sameValue("abab".match(/(..)(?<=\1\1\1)/), null, "#16"); +assert.sameValue("fabxbab".match(/(..)(?<=\1\1\1)/), null, "#17"); +assert.sameValue("faxabab".match(/(..)(?<=\1\1\1)/), null, "#18"); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/browser.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/captures-negative.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/captures-negative.js new file mode 100644 index 0000000000..966d505910 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/captures-negative.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: > + Captures inside negative lookbehind. (They never capture.) +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +assert.compareArray("abcdef".match(/(? + Capturing matches +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +var str = "abcdef"; +assert.compareArray(str.match(/(?<=(c))def/), ["def", "c"], "#1"); +assert.compareArray(str.match(/(?<=(\w{2}))def/), ["def", "bc"], "#2"); +assert.compareArray(str.match(/(?<=(\w(\w)))def/), ["def", "bc", "c"], "#3"); +assert.compareArray(str.match(/(?<=(\w){3})def/), ["def", "a"], "#4"); +assert.compareArray(str.match(/(?<=(bc)|(cd))./), ["d", "bc", undefined], "#5"); +assert.compareArray(str.match(/(?<=([ab]{1,2})\D|(abc))\w/), ["c", "a", undefined], "#6"); +assert.compareArray(str.match(/\D(?<=([ab]+))(\w)/), ["ab", "a", "b"], "#7"); +assert.compareArray(str.match(/(?<=b|c)\w/g), ["c", "d"], "#8"); +assert.compareArray(str.match(/(?<=[b-e])\w{2}/g), ["cd", "ef"], "#9"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/do-not-backtrack.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/do-not-backtrack.js new file mode 100644 index 0000000000..ee44a50ea6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/do-not-backtrack.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: Do not backtrack into a lookbehind. +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +---*/ + +// The lookbehind captures "abc" so that \1 does not match. We do not backtrack +// to capture only "bc" in the lookbehind. +assert.sameValue("abcdbc".match(/(?<=([abc]+)).\1/), null); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/greedy-loop.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/greedy-loop.js new file mode 100644 index 0000000000..bd8285a740 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/greedy-loop.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: Greedy loop +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +assert.compareArray("abbbbbbc".match(/(?<=(b+))c/), ["c", "bbbbbb"], "#1"); +assert.compareArray("ab1234c".match(/(?<=(b\d+))c/), ["c", "b1234"], "#2"); +assert.compareArray("ab12b23b34c".match(/(?<=((?:b\d{2})+))c/), ["c", "b12b23b34"], "#3"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/lookBehind/misc.js b/js/src/tests/test262/built-ins/RegExp/lookBehind/misc.js new file mode 100644 index 0000000000..b925a5c49c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/lookBehind/misc.js @@ -0,0 +1,39 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assertion +description: Misc RegExp lookbehind tests +info: | + The production Assertion :: (?<=Disjunction) evaluates as follows: + 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. + 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation + c, and performs the following steps: + a. Let d be a Continuation that always returns its State argument as a successful MatchResult. + b. Call m(x, d) and let r be its result. + c. If r is failure, return failure. + d. Let y be r's State. + e. Let cap be y's captures List. + f. Let xe be x's endIndex. + g. Let z be the State (xe, cap). + h. Call c(z) and return its result. +features: [regexp-lookbehind] +includes: [compareArray.js] +---*/ + +assert.sameValue("abcdef".match(/(?<=$abc)def/), null, "#1"); +assert.sameValue("fno".match(/^f.o(?<=foo)$/), null, "#2"); +assert.sameValue("foo".match(/^foo(?