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

added check for logging negative zero #298

Merged
merged 4 commits into from
Nov 3, 2014

Conversation

dasilvacontin
Copy link
Contributor

As @Lexicality mentions in issue #223, when asserting 0 against -0, Chai throws AssertionError: expected 0 to deeply equal 0 without any further information.

With the check in this PR, Chai throws AssertionError: expected 0 to deeply equal -0.

@@ -191,6 +191,9 @@ function formatPrimitive(ctx, value) {
return ctx.stylize(simple, 'string');

case 'number':
if (value === 0 && Infinity !== (1 / value)) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice work @dasilvacontin but there is some serious reverse logic going on here. Surely this would be better written as value === 0 && (1/value) === -Infinity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally agree with that! Thanks for pointing it out, @keithamus ! 😄

@keithamus
Copy link
Member

LGTM. @logicalparadox am I good to merge?

@logicalparadox
Copy link
Member

Missing test asserting this works.

@Lexicality
Copy link

👍

@dasilvacontin
Copy link
Contributor Author

Added some assertions. If it needs any other change, suggestions are welcome.

@logicalparadox
Copy link
Member

👍

keithamus added a commit that referenced this pull request Nov 3, 2014
added check for logging negative zero
@keithamus keithamus merged commit 3e35adf into chaijs:master Nov 3, 2014
@keithamus
Copy link
Member

Sorry @logicalparadox about missing the test - I'll ensure to be extra vigilant next time!

@dasilvacontin
Copy link
Contributor Author

Sorry for missing it too! :/

@dasilvacontin dasilvacontin deleted the negativeZeroLogging branch November 27, 2014 15:16
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.

None yet

4 participants