1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:17:44 +00:00

LibJS: Implement Set.prototype.intersection

This commit is contained in:
Idan Horowitz 2022-12-01 22:17:43 +02:00 committed by Linus Groh
parent fee65f6453
commit 9e693304ff
4 changed files with 95 additions and 0 deletions

View file

@ -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());
}
});