import { expect, test } from "vitest"; import { box } from "./box.ts"; import MapArray from "./MapArray.ts"; test("MapArray", () => { const mapArray = new MapArray([ ["a", box(1)], ["b", box(2)], ["c", box(3)], ]); mapArray.set("foo", box(42)); mapArray.set("bar", box(0)); mapArray.delete("bar"); expect(mapArray.get("foo")!.value).toBe(42); expect(mapArray.get("bar")).toBe(undefined); expect(mapArray.map.size).toBe(mapArray.array.length); expect( mapArray.entries().reduce( (a, c) => { a[1].value = a[1].value + c[1].value; return a; }, ["_", box(0)], )[1].value, ).toBe(48); });