Debian Codegraph @

js/src/tests/test262/staging/set-is-subset-table-transition.js

raw
1 // Copyright (C) 2023 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: Test isSubsetOf set method after table transition in receiver.
5 features: [set-methods]
6 ---*/
7
8 const firstSet = new Set();
9 firstSet.add(42);
10 firstSet.add(43);
11 firstSet.add(44);
12
13 const setLike = {
14 size: 5,
15 keys() {
16 return [1, 2, 3, 4, 5].keys();
17 },
18 has(key) {
19 if (key == 42) {
20 // Cause a table transition in the receiver.
21 firstSet.clear();
22 }
23 // Return true so we keep iterating the transitioned receiver.
24 return true;
25 }
26 };
27
28 assert.sameValue(firstSet.isSubsetOf(setLike), true);
29 assert.sameValue(firstSet.size, 0);
30
31 reportCompare(0, 0);