summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Set/prototype/isSupersetOf/allows-set-like-class.js
blob: cd5a45492c21655e0dc9946c50e785bafe370030 (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
// |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.issupersetof
description: GetSetRecord allows instances of Set-like classes
info: |
    1. If obj is not an Object, throw a TypeError exception.
    2. Let rawSize be ? Get(obj, "size").
    ...
    7. Let has be ? Get(obj, "has").
    ...
    9. Let keys be ? Get(obj, "keys").
features: [set-methods]
---*/

const s1 = new Set([1, 2]);
const s2 = new class {
  get size() {
    return 1;
  }
  has(v) {
    throw new Test262Error("Set.prototype.isSupersetOf should not call its argument's has method");
  }
  * keys() {
    yield 1;
  }
};

assert.sameValue(s1.isSupersetOf(s2), true);

reportCompare(0, 0);