summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-not-callable.js
blob: 647b38fb66d52c7472c04829d31e3661e9cc5aed (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) 2018 Peter Wong. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: Behavior when regexp[@@matchAll] is not callable
info: |
  String.prototype.matchAll ( regexp )
    [...]
    2. If regexp is neither undefined nor null, then
      a. Let matcher be ? GetMethod(regexp, @@matchAll).
features: [Symbol.matchAll, String.prototype.matchAll]
---*/

assert.sameValue(typeof String.prototype.matchAll, "function");

var regexp = /./;

regexp[Symbol.matchAll] = true;
assert.throws(TypeError, function() {
  ''.matchAll(regexp);
});

regexp[Symbol.matchAll] = 5;
assert.throws(TypeError, function() {
  ''.matchAll(regexp);
});

regexp[Symbol.matchAll] = '';
assert.throws(TypeError, function() {
  ''.matchAll(regexp);
});

regexp[Symbol.matchAll] = Symbol();
assert.throws(TypeError, function() {
  ''.matchAll(regexp);
});

reportCompare(0, 0);