mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibJS: Implement Set.prototype.intersection
This commit is contained in:
parent
fee65f6453
commit
9e693304ff
4 changed files with 95 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
test("basic functionality", () => {
|
||||
expect(Set.prototype.intersection).toHaveLength(1);
|
||||
|
||||
const set1 = new Set(["a", "b", "c"]);
|
||||
const set2 = new Set(["b", "c", "d", "e"]);
|
||||
const intersection1to2 = set1.intersection(set2);
|
||||
const intersection2to1 = set2.intersection(set1);
|
||||
for (const intersectionSet of [intersection1to2, intersection2to1]) {
|
||||
expect(intersectionSet).toHaveSize(2);
|
||||
["b", "c"].forEach(value => expect(intersectionSet.has(value)).toBeTrue());
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue