summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/staging/set-is-subset-table-transition.js
blob: 4ef9bf407ea587d3dc2287d472ecebd59813ff05 (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 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Test isSubsetOf set method after table transition in receiver.
features: [set-methods]
---*/

const firstSet = new Set();
firstSet.add(42);
firstSet.add(43);
firstSet.add(44);

const setLike = {
  size: 5,
  keys() {
    return [1, 2, 3, 4, 5].keys();
  },
  has(key) {
    if (key == 42) {
      // Cause a table transition in the receiver.
      firstSet.clear();
    }
    // Return true so we keep iterating the transitioned receiver.
    return true;
  }
};

assert.sameValue(firstSet.isSubsetOf(setLike), true);
assert.sameValue(firstSet.size, 0);

reportCompare(0, 0);