Add deepStrictEqual support - #6
Conversation
7f13e27 to
4cca0ce
Compare
4cca0ce to
310f8ab
Compare
d2d6656 to
c191cfa
Compare
kasperisager
left a comment
There was a problem hiding this comment.
This only scratches the surface of deep equality testing, see https://github.com/nodejs/node/blob/main/lib/internal/util/comparisons.js for the corresponding implementation in Node.js. We don't need to match that 1:1, but we should cover as much as is reasonable.
|
I'll double check a few more cases to cover; Currently, circular structures have false-positives for cases such as: https://github.com/nodejs/node/blob/main/test/parallel/test-assert-deep.js#L598-L607. Edit: I let two unit tests commented, those are limitations for the simplicity of the current memoization solution. |
13041df to
1f82d50
Compare
| if ( | ||
| prototype === BigInt.prototype || | ||
| prototype === Boolean.prototype || | ||
| prototype === Number.prototype || | ||
| prototype === String.prototype || | ||
| prototype === Symbol.prototype | ||
| ) { | ||
| return deepStrictEqualValue(a.valueOf(), b.valueOf(), memo) | ||
| } |
There was a problem hiding this comment.
Testing literal prototype identities won't work for cross-realm checks so we'll need additional libjs APIs for this, I'll add those. It's good enough for the initial implementation though 👌
There was a problem hiding this comment.
holepunchto/libjs#51, we can handle that in a separate PR once the new APIs are out.
kasperisager
left a comment
There was a problem hiding this comment.
I've added some additional test cases that must be covered as well to bring us mostly in line with the Node.js implementation.
|
I named the new utility class |
kasperisager
left a comment
There was a problem hiding this comment.
Solid progress! I added some more tests.
|
The comment "what matters is how many objects are reachable from the root before one repeats" gave me the hint of a possibility to simplify the strategy of memoization, and now, the comparison for cycles relies on the length of the circular objects.
|
fd108d9 to
f3e233b
Compare
kasperisager
left a comment
There was a problem hiding this comment.
Getting closer! I've added some more tests.
f957c93 to
e6c8f81
Compare
WIP - missing circular support.references and inspirations:
https://github.com/holepunchto/same-object
https://github.com/holepunchto/bare-inspect
https://github.com/chaijs/deep-eql/blob/main/index.js#L44-L89