-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deepEquals always fails on objects with arrays created with seamless-immutable #24
Comments
@glantucan Not sure how we'll fix this, but in the mean time, you can write your own validator using the Schematically: const compareImmutable = (reference) => (candidate) => {
const discrepancies = []
// actually compare `reference` and `candidate`, populate `discrepancies` if needed
return {pass: discrepancies.length === 0, message: discrepancies.join("\n")}
}
o("test", () => {
o(candidate).satisfies(compareImmutable(reference))
}) You'll probably want a recursive helper of the form _compareImmutable(reference, candidate, discrepancies) {} |
So, this is not something we can fix in core, as these objects are not deepEquals according to our definition, and out API leaves no room for adding an exception list. Here's a rudimentary port of deepEquals to support Edit: better demo |
Rethinking about this, I may have gotten this wrong... Non-enumerable properties are not compared on objects, we should skip them on arrays too for consistency. |
This is fixed in v4.1.6 |
Thanks for taking care of this :) |
deepEquals always fails on objects with arrays created with seamless-immutable, (or any other library that adds methods to the arrays)
ospec version: 4.1.1
Code:
The following test fails when it shouldn't
The problem seems to be here: https://github.com/MithrilJS/ospec/blob/master/ospec.js#L543
Ospec is using
Object.getOwnPropertyNames
on the array so it's finding non-enumerable functions and trying to compare them as well, and so it's finding non-enumerable functions and trying to compare them as well, rather than just ignoring them like it should.The text was updated successfully, but these errors were encountered: