blob: 8d31996491ee321cdc25ff1620d8915f7ffbd29a (
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
|
// |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 intersection method when `other` is a set-like.
features: [set-methods]
includes: [compareArray.js]
---*/
const SetLike = {
arr: [42, 43, 45],
size: 3,
keys() {
return this.arr[Symbol.iterator]();
},
has(key) {
return this.arr.indexOf(key) != -1;
}
};
const firstSet = new Set();
firstSet.add(42);
firstSet.add(43);
const resultSet = new Set();
resultSet.add(42);
resultSet.add(43);
const resultArray = Array.from(resultSet);
const intersectionArray = Array.from(firstSet.intersection(SetLike));
assert.compareArray(resultArray, intersectionArray);
reportCompare(0, 0);
|