-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
assert: use Same-value equality in deepStrictEqual #15398
Conversation
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.
LGTM if CI is green
doc/api/assert.md
Outdated
@@ -110,6 +110,9 @@ parameter is an instance of an `Error` then it will be thrown instead of the | |||
added: v1.2.0 | |||
changes: | |||
- version: REPLACEME | |||
pr-url: https://github.com/nodejs/node/pull/REPLACEME | |||
description: zero is now compared using the [Object.is][] comparison. |
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.
Nit: The fact that Object.is()
is used under the hood is probably not of interest to the end user compared to what the impact is for the end user. Like, if the big change is that +0
and -0
are no longer considered equal, maybe let's say that instead?
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.
Done
lib/assert.js
Outdated
@@ -118,12 +118,13 @@ function areSimilarRegExps(a, b) { | |||
// For small buffers it's faster to compare the buffer in a loop. The c++ | |||
// barrier including the Uint8Array operation takes the advantage of the faster | |||
// binary compare otherwise. The break even point was at about 300 characters. | |||
function areSimilarTypedArrays(a, b) { | |||
// NOTE: Floats should only use binary comparison in non strict mode! |
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.
Nit: Will this comment be clear to implementers? Would it be better to remove it and let tests catch any errors introduced by maintainers?
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.
Likely
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.
Sure, I removed the comment and the tests already include cases for this, so there is nothing to add anymore.
Landed in b0d3bec |
PR-URL: #15398 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: nodejs/node#15398 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: nodejs/node#15398 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
doc: fix http.ClientRequest method descriptions fix documentation for methods getHeader, setHeader and removeHeader for http.ClientRequest class. The documentation said these functions can be called but they're wasn't describe into the API description yet. add parameters and general description for each methods. PR-URL: nodejs#15163 Fixes: nodejs#15048 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> assert: use Same-value equality in deepStrictEqual PR-URL: nodejs#15398 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> formatting fix and scar deleted
This is one of the last changes I think is necessary to make
assert.deepStrictEqual
really great.As a side-effect I also improved the performance for Float*Array immensely. It depends on the size of the TypedArray but especially unequal ones will be found much, much faster now.
I also aligned Float*Array with other
TypedArray
s inassert.deepEqual
. This was not the case and it was tested stricter before (as in testing for extra properties).Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
assert