-
Notifications
You must be signed in to change notification settings - Fork 781
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
Prop equal against circular structures #776
Prop equal against circular structures #776
Conversation
I have signed the CLA several times now, but don't know why it doesn't seem so to jquerybot |
@@ -60,7 +60,8 @@ grunt.initConfig({ | |||
}, | |||
all: [ | |||
"<%= jshint.all %>", | |||
"!test/deepEqual.js" | |||
"!test/deepEqual.js", | |||
"!test/propEqual.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add more exceptions. We should fix any issues in new files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added test/propEqual.js to the exceptions because the tests in both files are almost the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but we shouldn't duplicate crappy code.
It looks like |
Not sure why the CLA check is failing, as far as I can tell your signature is fine. You can ignore that, I've pinged someone about that. |
As you said, I already removed Talking about #776 (comment), I think that when comparing objects, what most people actually want is comparing like propEqual does, but can't really know for sure. |
propEquiv.apply(this, args.splice( 1, args.length - 1 ) ) ); | ||
|
||
}, | ||
innerEquiv = deepEquiv; // default equivalence check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well drop innerEquiv
and assign deepEquiv.props
directly, then return that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that would totally make sense. How could propEquiv
be a member of deepEquiv
? They are kind of opposite. Something that could possibly be more natural would be to drop deepEquiv
and assign innerEquiv
and innerEquiv.props
directly. The point of this is not having that "linguistic contradiction" with propEquiv
being a subproperty of deepEquiv
.
Does that make any sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sticking with innerEquiv
is fine.
@Krinkle @JamesMGreene @leobalter any input on the discussion about general changes to |
I'm sorry I didn't give the proper attention to this PR, should we continue and update? |
I still think this is a valuable PR and we should try to pick it up and finish it. I just looked over the current stage again and while there's probably some minor details to fix (I noticed a missing end-of-file newline, so there are probably more style issues), overall this should be good to land. |
Before we put more time into this though, we should figure out what to do about #865. If we contribute our implementation to an external module and make use of that, we can (as easily) share code between |
does anyone want to continue the work on this? Should we close this at this point? |
I think this is still worth pursuing, but unless @BraulioVM wants to take this up again, it'd be best to close and open a new PR. |
It's been a couple more months, so I'm going to close this and hopefully we can address it in another PR. |
Made this pull request to fix issue #411
The problem within this issue was that propEqual was using the utility function objectValues, which does not check against circular structures, and then compared the result of both objectValues with a normal QUnit.equiv. As this approach does not work, I decided to split QUnit.equiv into two separate functions:
QUnit.equiv.deep
: which performs the old QUnit.equiv computationsQUnit.equiv.props
: which compares object properties, ignoring their constructor. This function does check against circular structures and allows propEqual to work as it should. If this function is passed a non-object parameter, aQUnit.equiv.deep
will be called.I also created some tests for this new function (mostly copied them from deepEqual.js tests).
Fixes #411