| 1 |
// Copyright (C) 2017 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
esid: sec-assertion |
| 6 |
description: Start of line matches |
| 7 |
info: | |
| 8 |
The production Assertion :: (?<=Disjunction) evaluates as follows: |
| 9 |
1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. |
| 10 |
2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation |
| 11 |
c, and performs the following steps: |
| 12 |
a. Let d be a Continuation that always returns its State argument as a successful MatchResult. |
| 13 |
b. Call m(x, d) and let r be its result. |
| 14 |
c. If r is failure, return failure. |
| 15 |
d. Let y be r's State. |
| 16 |
e. Let cap be y's captures List. |
| 17 |
f. Let xe be x's endIndex. |
| 18 |
g. Let z be the State (xe, cap). |
| 19 |
h. Call c(z) and return its result. |
| 20 |
features: [regexp-lookbehind] |
| 21 |
includes: [compareArray.js] |
| 22 |
---*/ |
| 23 |
|
| 24 |
assert.sameValue("abcdef".match(/(?<=^[^a-c]{3})def/), null, "#1"); |
| 25 |
assert.sameValue("foooo".match(/"^foooo(?<=^o+)$/), null, "#2"); |
| 26 |
assert.sameValue("foooo".match(/"^foooo(?<=^o*)$/), null, "#3"); |
| 27 |
|
| 28 |
assert.compareArray("abcdef".match(/(?<=^abc)def/), ["def"], "#4"); |
| 29 |
assert.compareArray("abcdef".match(/(?<=^[a-c]{3})def/), ["def"], "#5"); |
| 30 |
assert.compareArray("xyz\nabcdef".match(/(?<=^[a-c]{3})def/m), ["def"], "#6"); |
| 31 |
assert.compareArray("ab\ncd\nefg".match(/(?<=^)\w+/gm), ["ab", "cd", "efg"], "#7"); |
| 32 |
assert.compareArray("ab\ncd\nefg".match(/\w+(?<=$)/gm), ["ab", "cd", "efg"], "#8"); |
| 33 |
assert.compareArray("ab\ncd\nefg".match(/(?<=^)\w+(?<=$)/gm), ["ab", "cd", "efg"], "#9"); |
| 34 |
|
| 35 |
assert.compareArray("foo".match(/^foo(?<=^fo+)$/), ["foo"], "#10"); |
| 36 |
assert.compareArray("foooo".match(/^foooo(?<=^fo*)/), ["foooo"], "#11"); |
| 37 |
assert.compareArray("foo".match(/^(f)oo(?<=^\1o+)$/), ["foo", "f"], "#12"); |
| 38 |
assert.compareArray("foo".match(/^(f)oo(?<=^\1o+)$/i), ["foo", "f"], "#13"); |
| 39 |
assert.compareArray("foo\u1234".match(/^(f)oo(?<=^\1o+).$/i), ["foo\u1234", "f"], "#14"); |
| 40 |
assert.compareArray("abcdefdef".match(/(?<=^\w+)def/), ["def"], "#15"); |
| 41 |
assert.compareArray("abcdefdef".match(/(?<=^\w+)def/g), ["def", "def"], "#16"); |