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

Fix broken assert.equal assertion when not applied on a Collection #18

Merged
merged 3 commits into from
Jul 9, 2015

Conversation

matthewwithanm
Copy link
Contributor

This is an updated version of #16. I dug into the problem a little deeper to get a better understanding and figured out the actual root cause (essentially, not calling the original equal function.

…mutable collection

These tests currently fail. The result is some false positives!
You wouldn’t expect that this is necessary, however `assert.equal` and
the BDD version aren’t actually the same! The BDD version uses strict
equality while the “assert” version doesn’t. TIL.

This fixes the bug with testing equality of an Array and Immutable collection
with the "assert" style.
@astorije
Copy link
Owner

astorije commented Jul 6, 2015

Thanks, I'll take a look at this tomorrow! Sorry it got messy :-)

@matthewwithanm
Copy link
Contributor Author

Np. My original fix was 💩.

if (actual instanceof Collection) {
return new Assertion(actual).equal(expected);
}
else return assert.equal;
else return originalEqual(actual, expected);
Copy link
Owner

Choose a reason for hiding this comment

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

You nailed it, actually! The issue isn't so much that I didn't call the original assertion, but that I was returning a function, which never throws anything. And of course, not storing the original assertion somewhere triggers an infinite loop.
Good job!

That's one more proof we need more tests...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(:

@astorije astorije changed the title Immutable actuals Fix broken assert.equal assertion when not applied on a Collection Jul 9, 2015
astorije added a commit that referenced this pull request Jul 9, 2015
Fix broken assert.equal assertion when not applied on a Collection
@astorije astorije merged commit f4a68b1 into astorije:master Jul 9, 2015
@astorije
Copy link
Owner

astorije commented Jul 9, 2015

👍
Thanks a lot! I think this goes deeper than just your test case... Basically, the original assert.equal was never properly called for other types than Collection objects, so it's a pretty big deal!

Sorry it took time and 2 PRs to merge. Do you think it would be better to add a Gitter channel, or discussing over PR comments seemed enough?

@matthewwithanm
Copy link
Contributor Author

Yeah, sorry I didn't see it the first time. When I went back to it with a little spare time it jumped right out.

IMO Gitter would be overkill. Line comments are tied to the code in question and don't require immediate response.

Thanks for merging this!

@astorije astorije added the bug label Jul 9, 2015
@astorije
Copy link
Owner

astorije commented Jul 9, 2015

Voilà, it's released. I realized too late that it was a good candidate for 1.1.2, not 1.2.0, grr... Oh well.

@matthewwithanm
Copy link
Contributor Author

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants