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

assert: use Same-value equality in deepStrictEqual #15398

Closed
wants to merge 2 commits into from

Conversation

BridgeAR
Copy link
Member

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 TypedArrays in assert.deepEqual. This was not the case and it was tested stricter before (as in testing for extra properties).

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

assert

@BridgeAR BridgeAR added assert Issues and PRs related to the assert subsystem. performance Issues and PRs related to the performance of Node.js. semver-major PRs that contain breaking changes and should be released in the next major version. labels Sep 13, 2017
@nodejs-github-bot nodejs-github-bot added the assert Issues and PRs related to the assert subsystem. label Sep 13, 2017
@BridgeAR BridgeAR requested a review from Trott September 13, 2017 21:29
Copy link
Member

@Trott Trott left a 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

@@ -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.
Copy link
Member

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?

Copy link
Member Author

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!
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Likely

Copy link
Member Author

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.

@jasnell
Copy link
Member

jasnell commented Sep 15, 2017

@BridgeAR
Copy link
Member Author

Landed in b0d3bec

@BridgeAR BridgeAR closed this Sep 16, 2017
BridgeAR added a commit that referenced this pull request Sep 16, 2017
PR-URL: #15398
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 17, 2017
PR-URL: nodejs/node#15398
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
PR-URL: nodejs/node#15398
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
decareano added a commit to decareano/node that referenced this pull request Sep 22, 2017
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 <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

assert: use Same-value equality in deepStrictEqual

PR-URL: nodejs#15398
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>

formatting fix and scar deleted
@BridgeAR BridgeAR deleted the assert-minus-zero branch April 1, 2019 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. performance Issues and PRs related to the performance of Node.js. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants