-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Conversation
@@ -191,6 +191,9 @@ function formatPrimitive(ctx, value) { | |||
return ctx.stylize(simple, 'string'); | |||
|
|||
case 'number': | |||
if (value === 0 && Infinity !== (1 / value)) { |
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.
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
?
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 totally agree with that! Thanks for pointing it out, @keithamus ! 😄
LGTM. @logicalparadox am I good to merge? |
Missing test asserting this works. |
👍 |
Added some assertions. If it needs any other change, suggestions are welcome. |
👍 |
added check for logging negative zero
Sorry @logicalparadox about missing the test - I'll ensure to be extra vigilant next time! |
Sorry for missing it too! :/ |
As @Lexicality mentions in issue #223, when asserting
0
against-0
, Chai throwsAssertionError: 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
.