summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js
blob: fe120958cd3e2d5d9b75e1ba4cf7fcf979a00804 (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
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.split
description: >
  [[IsHTMLDDA]] object as @@split method gets called.
info: |
  String.prototype.split ( separator, limit )

  [...]
  2. If separator is neither undefined nor null, then
    a. Let splitter be ? GetMethod(separator, @@split).
    b. If splitter is not undefined, then
      i. Return ? Call(splitter, separator, « O, limit »).
features: [Symbol.split, IsHTMLDDA]
---*/

var separator = $262.IsHTMLDDA;
var splitterGets = 0;
Object.defineProperty(separator, Symbol.split, {
  get: function() {
    splitterGets += 1;
    return separator;
  },
  configurable: true,
});

assert.sameValue("".split(separator), null);
assert.sameValue(splitterGets, 1);

reportCompare(0, 0);