summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/g-match-empty-advance-lastindex.js
blob: 40787a069e3dfaaa8331969cb41e37f45333ed5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
    lastIndex is explicitly advanced for zero-length matches for "global"
    instances
es6id: 21.2.5.6
info: |
    7. If global is false, then
       [...]
    8. Else global is true,
       [...]
       g. Repeat,
          i. Let result be RegExpExec(rx, S).
          [...]
          iv. Else result is not null,
              [...]
              5. If matchStr is the empty String, then
                 [...]
                 c. Let nextIndex be AdvanceStringIndex(S, thisIndex,
                    fullUnicode).
                 d. Let setStatus be Set(rx, "lastIndex", nextIndex, true).
                 e. ReturnIfAbrupt(setStatus).
              6. Increment n.
features: [Symbol.match]
---*/

var result = /(?:)/g[Symbol.match]('abc');

assert.notSameValue(result, null);
assert.sameValue(result.length, 4);
assert.sameValue(result[0], '');
assert.sameValue(result[1], '');
assert.sameValue(result[2], '');
assert.sameValue(result[3], '');

reportCompare(0, 0);