denoland / std

The Deno Standard Library
https://jsr.io/@std
MIT License
3.17k stars 621 forks source link

`assertEquals` sometimes gives wrong result for complex keys #5912

Closed lionel-rowe closed 1 month ago

lionel-rowe commented 2 months ago

Describe the bug

assertEquals sometimes gives wrong result for complex keys

Steps to Reproduce

// throws
assertFalse(
  equal(new Set([{ b: 2 }, { a: 1 }]), new Set([{ a: 1 }, { b: 3 }])),
);

Caused by these 2 lines:

https://github.com/denoland/std/blob/d102a10235b5d8d569e08cf9b53902a650f91a1c/assert/equal.ts#L92-L93

Because compare can be called twice at the same level, and the results can be different due to checking seen, the results are sometimes wrong.

Expected behavior

assertEquals consistently gives correct result for complex keys

Environment

Latest std/assert

kt3k commented 1 month ago

Let's close this for now as the given example is now fixed

Please file a new issue if you find a new one