29 lines
591 B
JavaScript
29 lines
591 B
JavaScript
import assert from "node:assert";
|
|
|
|
import { compareInts, compareStrings } from "../lib/compare/primitives.js";
|
|
import { compareDicts } from "../lib/compare/structures.js";
|
|
import { emptyDict, set } from "../lib/structures/dict.js";
|
|
|
|
const cmpFn = compareDicts(compareStrings)(compareInts);
|
|
|
|
const e = emptyDict(compareStrings);
|
|
const f = set(e)("x")(1n);
|
|
const g = set(f)("y")(2n);
|
|
|
|
assert.equal(
|
|
cmpFn(e)(e),
|
|
0,
|
|
"empty dict should be equal to itself"
|
|
);
|
|
|
|
assert.equal(
|
|
cmpFn(g)(g),
|
|
0,
|
|
"dict should always equal itself"
|
|
);
|
|
|
|
assert.equal(
|
|
cmpFn(f)(g),
|
|
-1,
|
|
"f is smaller"
|
|
);
|