-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
util: assert: fix deepStrictEqual comparing a real array and fake array #30743
Conversation
@nodejs/assert |
684d1ce
to
81be8ab
Compare
- Skip one, pending nodejs/node#30743
- Skip one, pending nodejs/node#30743
81be8ab
to
3d7c1c7
Compare
- Skip one, pending nodejs/node#30743
- Skip one, pending nodejs/node#30743
test/parallel/test-assert-deep.js
Outdated
@@ -1064,7 +1079,7 @@ assert.throws( | |||
Object.defineProperty(a, 'length', { | |||
value: 2 | |||
}); | |||
assert.notDeepStrictEqual(a, [1, 1]); | |||
assertOnlyDeepEqual(a, [1, 1]); |
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.
this was the failing test, because it tries the arguments in reverse order
@@ -1050,6 +1050,21 @@ assert.throws( | |||
assert.deepStrictEqual(a, b); | |||
} | |||
|
|||
// Verify that an array and the equivalent fake array object |
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.
this test was previously passing, but it felt like a good addition anyways.
Does this require an update to the documented |
Codecov Report
@@ Coverage Diff @@
## master #30743 +/- ##
=========================================
Coverage ? 97.36%
=========================================
Files ? 187
Lines ? 62171
Branches ? 0
=========================================
Hits ? 60532
Misses ? 1639
Partials ? 0 Continue to review full report at Codecov.
|
@Trott all this change does is makes sure that what already works for |
I originally decided against doing full two sides checks because it's a very rare edge case and we can not check both sides for all types (we could do that for built-in types but that would be a lot of overhead). I am fine to implement this at least for the currently used one sided type checks. That way it's always consistent, no matter what argument is first. It would be good to keep the performance overhead in mind though. Especially the typed array type check is relatively expensive. @ljharb I went ahead and opened #30764 as alternative to this one as it addresses all open one sides versions with the least overhead possible. |
This veryfies that both input arguments are always of the identical type. It was possible to miss a few cases before. This change applies to all deep equal assert functions (e.g., `assert.deepStrictEqual()`) and to `util.isDeepStrictEqual()`. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
This makes sure the assertion does not depend on the argument order. It also removes comments that do not apply anymore and verifies the behavior for the loose and strict implementation. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Now that #30764 has landed, I'll update or close this PR soon, based on if there's anything of value left in it. |
3d7c1c7
to
de24d40
Compare
I updated the PR; there's just a single test case left. Feel free to land or close. |
de24d40
to
66a3dc4
Compare
This veryfies that both input arguments are always of the identical type. It was possible to miss a few cases before. This change applies to all deep equal assert functions (e.g., `assert.deepStrictEqual()`) and to `util.isDeepStrictEqual()`. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
This makes sure the assertion does not depend on the argument order. It also removes comments that do not apply anymore and verifies the behavior for the loose and strict implementation. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: #30743 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Landed in 916cc82 |
PR-URL: #30743 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
PR-URL: #30743 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This veryfies that both input arguments are always of the identical type. It was possible to miss a few cases before. This change applies to all deep equal assert functions (e.g., `assert.deepStrictEqual()`) and to `util.isDeepStrictEqual()`. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
This makes sure the assertion does not depend on the argument order. It also removes comments that do not apply anymore and verifies the behavior for the loose and strict implementation. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: #30743 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This veryfies that both input arguments are always of the identical type. It was possible to miss a few cases before. This change applies to all deep equal assert functions (e.g., `assert.deepStrictEqual()`) and to `util.isDeepStrictEqual()`. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
This makes sure the assertion does not depend on the argument order. It also removes comments that do not apply anymore and verifies the behavior for the loose and strict implementation. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes(following in the tradition of #29029)