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

LibJS: Implement Set.prototype.difference

This commit is contained in:
Idan Horowitz 2022-12-01 22:33:26 +02:00 committed by Linus Groh
parent 9e693304ff
commit be8329d5f6
4 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,12 @@
test("basic functionality", () => {
expect(Set.prototype.difference).toHaveLength(1);
const set1 = new Set(["a", "b", "c"]);
const set2 = new Set(["b", "c", "d", "e"]);
const difference1to2 = set1.difference(set2);
expect(difference1to2).toHaveSize(1);
expect(difference1to2.has("a")).toBeTrue();
const difference2to1 = set2.difference(set1);
expect(difference2to1).toHaveSize(2);
["d", "e"].forEach(value => expect(difference2to1.has(value)).toBeTrue());
});