Skip to content

Commit f633cef

Browse files
committed
Add tests of storing tuples in Map and Set containers.
1 parent 12d691b commit f633cef

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/tests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,34 @@ describe("tuple basics", function () {
3232
esTuple("tuple","am","I").reverse()
3333
);
3434
});
35+
36+
it("should be usable as Map keys", function () {
37+
const map = new Map;
38+
39+
assert.strictEqual(map.has(tuple(1, tuple(2, "buckle"), true)), false);
40+
map.set(tuple(1, tuple(2, "buckle"), true), "oh my");
41+
assert.strictEqual(map.has(tuple(1, tuple(2, "buckle"), true)), true);
42+
assert.strictEqual(map.get(tuple(1, tuple(2, "buckle"), true)), "oh my");
43+
44+
map.forEach(function (value, key) {
45+
assert.strictEqual(key, tuple(1, tuple(2, "buckle"), true));
46+
assert.strictEqual(value, "oh my");
47+
});
48+
49+
map.delete(tuple(1, tuple(2, "buckle"), true));
50+
map.forEach(function () {
51+
throw new Error("unreached");
52+
});
53+
});
54+
55+
it("should be storable in a Set", function () {
56+
const set = new Set([
57+
tuple(1, 2, tuple(3, 4), 5),
58+
tuple(1, 2, tuple(3, 4), 5),
59+
]);
60+
61+
assert.strictEqual(set.size, 1);
62+
});
3563
});
3664

3765
describe("Array methods", function () {

0 commit comments

Comments
 (0)