summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/last-index-exceeds-str-size.js
blob: d229f5b8f9624dd169a78c2bbaebe1b4b30b8016 (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
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-regexp.prototype-@@split
description: The `lastIndex` property is clamped to the string size.
info: |
  RegExp.prototype [ @@split ] ( string, limit )

  ...
  19. Repeat, while q < size
    ...
    d. Else z is not null,
      i. Let e be ? ToLength(Get(splitter, "lastIndex")).
      ii. Let e be min(e, size).
  ...
features: [Symbol.split]
---*/

var regExp = /a/;
var string = "foo";

RegExp.prototype.exec = function() {
  this.lastIndex = 100;
  return {length: 0, index: 0};
};

var result = regExp[Symbol.split](string);

assert.sameValue(result.length, 2, "result.length");
assert.sameValue(result[0], "", "result[0]");
assert.sameValue(result[1], "", "result[1]");

reportCompare(0, 0);