summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Set/prototype/intersection/has-is-callable.js
blob: 5a90f12de7ace915007a6ad05d6aee62a48953b8 (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
39
// |reftest| skip -- set-methods is not supported
// Copyright (C) 2023 Anthony Frehner and Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-getsetrecord
description: GetSetRecord throws an exception if the Set-like object's 'has' property is not callable
info: |
    7. Let has be ? Get(obj, "has").
    8. If IsCallable(has) is false, throw a TypeError exception.
features: [set-methods]
---*/

const s1 = new Set([1, 2]);
const s2 = {
  size: 2,
  has: undefined,
  keys: function* keys() {
    yield 2;
    yield 3;
  },
};
assert.throws(
  TypeError,
  function () {
    s1.intersection(s2);
  },
  "GetSetRecord throws an error when has is undefined"
);

s2.has = {};
assert.throws(
  TypeError,
  function () {
    s1.intersection(s2);
  },
  "GetSetRecord throws an error when has is not callable"
);

reportCompare(0, 0);