From 8cb7f593950a77e3a17b520fea5ec9414a56879b Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 25 Apr 2017 16:06:15 +0200 Subject: [PATCH 1/4] Create an assert.compareArray This is a convenience function which tries to make tests easier to read and write. --- harness/compareArray.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/harness/compareArray.js b/harness/compareArray.js index 6eb69e6eba0..0e0654aeb4e 100644 --- a/harness/compareArray.js +++ b/harness/compareArray.js @@ -13,3 +13,17 @@ function compareArray(a, b) { return true; } +assert.compareArray = function(actual, expected, message) { + if (compareArray(actual, expected)) return; + + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + String(actual) + '», «' + String(expected) + '») to be true'; + + $ERROR(`${message}${message === undefined ? '' : ' '}Expected the arrays [${actual}] to have the same contents as [${expected}]`); +} From 6ee183a0578d45f4a4cf34bd4bd838e3fb918f95 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Tue, 25 Apr 2017 16:06:57 +0200 Subject: [PATCH 2/4] RegExp lookbehind tests Tests for the stage 3 proposal at https://tc39.github.io/proposal-regexp-lookbehind/ Tests ported from V8, written by @hashseed --- test/built-ins/RegExp/lookbehind.js | 169 +++++++++++++++++++ test/built-ins/RegExp/negative-lookbehind.js | 34 ++++ 2 files changed, 203 insertions(+) create mode 100644 test/built-ins/RegExp/lookbehind.js create mode 100644 test/built-ins/RegExp/negative-lookbehind.js diff --git a/test/built-ins/RegExp/lookbehind.js b/test/built-ins/RegExp/lookbehind.js new file mode 100644 index 00000000000..b792a80d6f7 --- /dev/null +++ b/test/built-ins/RegExp/lookbehind.js @@ -0,0 +1,169 @@ +// 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: Test RegExp 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] +---*/ + +// Simple fixed-length matches. +assert.compareArray(["a"], "a".match(/^.(?<=a)/)); +assert.sameValue(null, "b".match(/^.(?<=a)/)); +assert.compareArray(["foo"], "foo1".match(/^f..(?<=.oo)/)); +assert.compareArray(["foo"], "foo2".match(/^f\w\w(?<=\woo)/)); +assert.sameValue(null, "boo".match(/^f\w\w(?<=\woo)/)); +assert.sameValue(null, "fao".match(/^f\w\w(?<=\woo)/)); +assert.sameValue(null, "foa".match(/^f\w\w(?<=\woo)/)); +assert.compareArray(["def"], "abcdef".match(/(?<=abc)\w\w\w/)); +assert.compareArray(["def"], "abcdef".match(/(?<=a.c)\w\w\w/)); +assert.compareArray(["def"], "abcdef".match(/(?<=a\wc)\w\w\w/)); +assert.compareArray(["cde"], "abcdef".match(/(?<=a[a-z])\w\w\w/)); +assert.compareArray(["def"], "abcdef".match(/(?<=a[a-z][a-z])\w\w\w/)); +assert.compareArray(["def"], "abcdef".match(/(?<=a[a-z]{2})\w\w\w/)); +assert.compareArray(["bcd"], "abcdef".match(/(?<=a{1})\w\w\w/)); +assert.compareArray(["cde"], "abcdef".match(/(?<=a{1}b{1})\w\w\w/)); +assert.compareArray(["def"], "abcdef".match(/(?<=a{1}[a-z]{2})\w\w\w/)); + +// Variable-length matches. +assert.compareArray(["def"], "abcdef".match(/(?<=[a|b|c]*)[^a|b|c]{3}/)); +assert.compareArray(["def"], "abcdef".match(/(?<=\w*)[^a|b|c]{3}/)); + +// Start of line matches. +assert.compareArray(["def"], "abcdef".match(/(?<=^abc)def/)); +assert.compareArray(["def"], "abcdef".match(/(?<=^[a-c]{3})def/)); +assert.compareArray(["def"], "xyz\nabcdef".match(/(?<=^[a-c]{3})def/m)); +assert.compareArray(["ab", "cd", "efg"], "ab\ncd\nefg".match(/(?<=^)\w+/gm)); +assert.compareArray(["ab", "cd", "efg"], "ab\ncd\nefg".match(/\w+(?<=$)/gm)); +assert.compareArray(["ab", "cd", "efg"], "ab\ncd\nefg".match(/(?<=^)\w+(?<=$)/gm)); +assert.sameValue(null, "abcdef".match(/(?<=^[^a-c]{3})def/)); +assert.sameValue(null, "foooo".match(/"^foooo(?<=^o+)$/)); +assert.sameValue(null, "foooo".match(/"^foooo(?<=^o*)$/)); +assert.compareArray(["foo"], "foo".match(/^foo(?<=^fo+)$/)); +assert.compareArray(["foooo"], "foooo".match(/^foooo(?<=^fo*)/)); +assert.compareArray(["foo", "f"], "foo".match(/^(f)oo(?<=^\1o+)$/)); +assert.compareArray(["foo", "f"], "foo".match(/^(f)oo(?<=^\1o+)$/i)); +assert.compareArray(["foo\u1234", "f"], "foo\u1234".match(/^(f)oo(?<=^\1o+).$/i)); +assert.compareArray(["def"], "abcdefdef".match(/(?<=^\w+)def/)); +assert.compareArray(["def", "def"], "abcdefdef".match(/(?<=^\w+)def/g)); + +// Word boundary matches. +assert.compareArray(["def"], "abc def".match(/(?<=\b)[d-f]{3}/)); +assert.compareArray(["def"], "ab cdef".match(/(?<=\B)\w{3}/)); +assert.compareArray(["def"], "ab cdef".match(/(?<=\B)(?<=c(?<=\w))\w{3}/)); +assert.sameValue(null, "abcdef".match(/(?<=\b)[d-f]{3}/)); + +// Capturing matches. +assert.compareArray(["def", "c"], "abcdef".match(/(?<=(c))def/)); +assert.compareArray(["def", "bc"], "abcdef".match(/(?<=(\w{2}))def/)); +assert.compareArray(["def", "bc", "c"], "abcdef".match(/(?<=(\w(\w)))def/)); +assert.compareArray(["def", "a"], "abcdef".match(/(?<=(\w){3})def/)); +assert.compareArray(["d", "bc", undefined], "abcdef".match(/(?<=(bc)|(cd))./)); +assert.compareArray(["c", "a", undefined], + "abcdef".match(/(?<=([ab]{1,2})\D|(abc))\w/)); +assert.compareArray(["ab", "a", "b"], "abcdef".match(/\D(?<=([ab]+))(\w)/)); +assert.compareArray(["c", "d"], "abcdef".match(/(?<=b|c)\w/g)); +assert.compareArray(["cd", "ef"], "abcdef".match(/(?<=[b-e])\w{2}/g)); + +// Captures inside negative lookbehind. (They never capture.) +assert.compareArray(["de", undefined], "abcdef".match(/(? Date: Wed, 26 Apr 2017 14:05:31 +0200 Subject: [PATCH 3/4] Fix up compareArray --- harness/compareArray.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/harness/compareArray.js b/harness/compareArray.js index 0e0654aeb4e..228a6aaaecf 100644 --- a/harness/compareArray.js +++ b/harness/compareArray.js @@ -14,16 +14,6 @@ function compareArray(a, b) { } assert.compareArray = function(actual, expected, message) { - if (compareArray(actual, expected)) return; - - - if (message === undefined) { - message = ''; - } else { - message += ' '; - } - - message += 'Expected SameValue(«' + String(actual) + '», «' + String(expected) + '») to be true'; - - $ERROR(`${message}${message === undefined ? '' : ' '}Expected the arrays [${actual}] to have the same contents as [${expected}]`); + assert(compareArray(actual, expected), + `Expected [${actual.join(", ")}] and [${expected.join(", ")}] to have the same contents. ${message}`); } From 0f10d73fefeecb22d9e6b1aff0f9508bc077f6e3 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Thu, 27 Apr 2017 19:32:52 -0400 Subject: [PATCH 4/4] Split tests and fix actual/expected order --- .../RegExp/lookBehind/alternations.js | 27 +++ .../lookBehind/back-references-to-captures.js | 29 +++ .../RegExp/lookBehind/back-references.js | 43 +++++ .../RegExp/lookBehind/captures-negative.js | 25 +++ test/built-ins/RegExp/lookBehind/captures.js | 34 ++++ .../RegExp/lookBehind/do-not-backtrack.js | 25 +++ .../RegExp/lookBehind/greedy-loop.js | 26 +++ test/built-ins/RegExp/lookBehind/misc.js | 37 ++++ .../RegExp/lookBehind/mutual-recursive.js | 27 +++ test/built-ins/RegExp/lookBehind/negative.js | 32 ++++ .../RegExp/lookBehind/nested-lookaround.js | 29 +++ .../RegExp/lookBehind/simple-fixed-length.js | 40 +++++ .../RegExp/lookBehind/sliced-strings.js | 20 +++ .../RegExp/lookBehind/start-of-line.js | 41 +++++ test/built-ins/RegExp/lookBehind/sticky.js | 30 ++++ .../RegExp/lookBehind/variable-length.js | 25 +++ .../RegExp/lookBehind/word-boundary.js | 28 +++ test/built-ins/RegExp/lookbehind.js | 169 ------------------ test/built-ins/RegExp/negative-lookbehind.js | 34 ---- 19 files changed, 518 insertions(+), 203 deletions(-) create mode 100644 test/built-ins/RegExp/lookBehind/alternations.js create mode 100644 test/built-ins/RegExp/lookBehind/back-references-to-captures.js create mode 100644 test/built-ins/RegExp/lookBehind/back-references.js create mode 100644 test/built-ins/RegExp/lookBehind/captures-negative.js create mode 100644 test/built-ins/RegExp/lookBehind/captures.js create mode 100644 test/built-ins/RegExp/lookBehind/do-not-backtrack.js create mode 100644 test/built-ins/RegExp/lookBehind/greedy-loop.js create mode 100644 test/built-ins/RegExp/lookBehind/misc.js create mode 100644 test/built-ins/RegExp/lookBehind/mutual-recursive.js create mode 100644 test/built-ins/RegExp/lookBehind/negative.js create mode 100644 test/built-ins/RegExp/lookBehind/nested-lookaround.js create mode 100644 test/built-ins/RegExp/lookBehind/simple-fixed-length.js create mode 100644 test/built-ins/RegExp/lookBehind/sliced-strings.js create mode 100644 test/built-ins/RegExp/lookBehind/start-of-line.js create mode 100644 test/built-ins/RegExp/lookBehind/sticky.js create mode 100644 test/built-ins/RegExp/lookBehind/variable-length.js create mode 100644 test/built-ins/RegExp/lookBehind/word-boundary.js delete mode 100644 test/built-ins/RegExp/lookbehind.js delete mode 100644 test/built-ins/RegExp/negative-lookbehind.js diff --git a/test/built-ins/RegExp/lookBehind/alternations.js b/test/built-ins/RegExp/lookBehind/alternations.js new file mode 100644 index 00000000000..e83c784196c --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/alternations.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: 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"); diff --git a/test/built-ins/RegExp/lookBehind/back-references-to-captures.js b/test/built-ins/RegExp/lookBehind/back-references-to-captures.js new file mode 100644 index 00000000000..9a09d0203b0 --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/back-references-to-captures.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: 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"); diff --git a/test/built-ins/RegExp/lookBehind/back-references.js b/test/built-ins/RegExp/lookBehind/back-references.js new file mode 100644 index 00000000000..062bff03394 --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/back-references.js @@ -0,0 +1,43 @@ +// 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"); + diff --git a/test/built-ins/RegExp/lookBehind/captures-negative.js b/test/built-ins/RegExp/lookBehind/captures-negative.js new file mode 100644 index 00000000000..f745d0f8118 --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/captures-negative.js @@ -0,0 +1,25 @@ +// 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"); diff --git a/test/built-ins/RegExp/lookBehind/do-not-backtrack.js b/test/built-ins/RegExp/lookBehind/do-not-backtrack.js new file mode 100644 index 00000000000..2aaf2264e60 --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/do-not-backtrack.js @@ -0,0 +1,25 @@ +// 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); diff --git a/test/built-ins/RegExp/lookBehind/greedy-loop.js b/test/built-ins/RegExp/lookBehind/greedy-loop.js new file mode 100644 index 00000000000..c59daad5093 --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/greedy-loop.js @@ -0,0 +1,26 @@ +// 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"); diff --git a/test/built-ins/RegExp/lookBehind/misc.js b/test/built-ins/RegExp/lookBehind/misc.js new file mode 100644 index 00000000000..887356ea133 --- /dev/null +++ b/test/built-ins/RegExp/lookBehind/misc.js @@ -0,0 +1,37 @@ +// 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(?