Skip to content
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

Immutable actuals #16

Closed

Conversation

matthewwithanm
Copy link
Contributor

We're getting some false positives in our equals comparisons!

Turns out it's because Immutable.is is only used when the "actual" value is an Immutable collection. This fixes it.

@matthewwithanm
Copy link
Contributor Author

Oops. The problem is actually when only the expected value is an Immutable collection. Updated my commit messages and test descriptions.

@astorije
Copy link
Owner

astorije commented Jul 3, 2015

Hi @matthewwithanm, thanks for the contribution (and sorry for the delay, I was finally taking some vacations :-) ).
I am wondering, did you push the updates you are mentioning in your comment?

@matthewwithanm
Copy link
Contributor Author

Np. Yeah, I amended the commit.

@astorije
Copy link
Owner

astorije commented Jul 4, 2015

Ah right, thanks @matthewwithanm I am reviewing right now.

@@ -71,7 +71,7 @@ module.exports = function (chai, utils) {
return function (collection) {
var obj = this._obj;

if (obj && obj instanceof Collection) {
if (obj && obj instanceof Collection || collection instanceof Collection) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewwithanm, I'm not sure I see why we need this.

Currently:

expect([]).to.not.equal(List.of(1, 2, 3)); // Passes
expect([]).to.equal(List.of(1, 2, 3)); // Fails with "AssertionError: expected [] to equal List [ 1, 2, 3 ]"

which seems like what we should expect: if obj is not a Collection, the equality assertion is deferred to the original assertion.

Is there something I am I missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yeah it doesn't seem like we do…sorry, I can't remember anymore! I can remove it and see if we stumble on why again. Sound good?

Create new functions using `function` instead of `bind` and always use
the BDD style to test.
@matthewwithanm
Copy link
Contributor Author

Going to push a new PR…I think the real issue is that assert.equal is calling itself instead of the original version. Currently trying to figure out why we need to do that at all (it seems like Assertion should take care of that when it calls _super).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants