Bug
stringify() returns the literal string "{}" for Set and Map values, regardless of their contents.
src/objects.js:270-272:
case "Set":
case "Map":
return "{}";
Impact
Failing tests that compare these types produce uninformative output. With default deep equality, equals(new Set([1, 2, 3]), new Set([4, 5])) correctly returns false, but the failure message renders both sides as {}. The new formatDiff strategy picker (PR #127) falls back to the "stringified identically but not equal" hint — accurate but unhelpful.
Repro
import { equals } from "htest.dev/check";
export default {
name: "Set diff",
run: () => new Set([1, 2, 3]),
expect: new Set([4, 5]),
check: equals,
};
Output:
Actual: {} (Set)
Expected: {} (Set)
(values are stringified identically but not equal)
Fix sketch
Serialize Set and Map by walking their entries — similar to how Array is handled at src/objects.js:273-279.
Once fixed, the format-diff strategies (inline char-diff, multi-line -/+ block) handle these values correctly without further changes.
Related
Bug
stringify()returns the literal string"{}"forSetandMapvalues, regardless of their contents.src/objects.js:270-272:
Impact
Failing tests that compare these types produce uninformative output. With default deep equality,
equals(new Set([1, 2, 3]), new Set([4, 5]))correctly returnsfalse, but the failure message renders both sides as{}. The newformatDiffstrategy picker (PR #127) falls back to the "stringified identically but not equal" hint — accurate but unhelpful.Repro
Output:
Fix sketch
Serialize
SetandMapby walking their entries — similar to howArrayis handled at src/objects.js:273-279.Once fixed, the format-diff strategies (inline char-diff, multi-line
-/+block) handle these values correctly without further changes.Related
.sourceand.flags#48 (RegExp equality fix) — covers the RegExp half of the samecaseblock