summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Set/prototype/isSubsetOf/receiver-not-set.js
blob: 6b55d46e2a1cd04058a5a45fc863acd0174596f1 (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
40
41
42
43
44
45
46
47
// |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-set.prototype.issubsetof
description: Set.prototype.isSubsetOf throws when receiver is not a Set
features: [set-methods]
---*/

class MySetLike {
  constructor() {
    this.size = 2;
    this.has = () => {};
    this.keys = function* keys() {
      yield 2;
      yield 3;
    };
  }
}

const s1 = new MySetLike();
const s2 = new Set();
assert.throws(
  TypeError,
  () => {
    Set.prototype.isSubsetOf.call(s1, s2);
  },
  "Set-like class"
);

const s3 = {
  size: 2,
  has: () => {},
  keys: function* keys() {
    yield 2;
    yield 3;
  },
};
assert.throws(
  TypeError,
  () => {
    Set.prototype.isSubsetOf.call(s3, s2);
  },
  "Set-like object"
);

reportCompare(0, 0);