summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/RegExp/prototype/Symbol.split/Symbol.match-getter-recompiles-source.js
blob: 41e8cbaf191c79a27e57a0bef4fd58a8504381e2 (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
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-regexp.prototype-@@split
description: >
  Side-effects in IsRegExp may recompile the regular expression.
info: |
  21.2.5.11 RegExp.prototype [ @@split ] ( string, limit )
    ...
    4. Let C be ? SpeciesConstructor(rx, %RegExp%).
    ...
    10. Let splitter be ? Construct(C, « rx, newFlags »).
    ...

  21.2.3.1 RegExp ( pattern, flags )
    1. Let patternIsRegExp be ? IsRegExp(pattern).
    ...

features: [Symbol.match, Symbol.split]
---*/

var regExp = /a/;
Object.defineProperty(regExp, Symbol.match, {
  get: function() {
    regExp.compile("b");
  }
});

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

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

reportCompare(0, 0);