1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

LibJS: Implement Set.prototype.union

This commit is contained in:
Idan Horowitz 2022-12-01 23:04:30 +02:00 committed by Linus Groh
parent 8e1df36588
commit fee65f6453
6 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,12 @@
test("basic functionality", () => {
expect(Set.prototype.union).toHaveLength(1);
const set1 = new Set(["a", "b", "c"]);
const set2 = new Set(["b", "c", "d"]);
const union1to2 = set1.union(set2);
const union2to1 = set2.union(set1);
for (const unionSet of [union1to2, union2to1]) {
expect(unionSet).toHaveSize(4);
["a", "b", "c", "d"].forEach(value => expect(unionSet.has(value)).toBeTrue());
}
});