GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — assert: add deep equal check for more Error type by kylo5aby · Pull Request #51805 · nodejs/node Conversation
Contributor
add deep equal check for the cases below:
Fixes: #51793
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
BridgeAR
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already looking very promising! The documentation still needs an update (we describe what properties we check in addition to enumerable ones) and I left improvement suggestions for edge cases.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This check would currently miss the case, if either side is an
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely the right check as long the property is non-enumerable. If it is enumerable, we'd do the check twice and this could be costly and a lot of errors are created in the wild with a cause property set as an enumerable one. In addition, we should also verify that the properties have the same enumerability. We don't yet do that for const cause1Enumerable = ObjectPrototypePropertyIsEnumerable(val1, 'cause'); if (cause1Enumerable !== ObjectPrototypePropertyIsEnumerable(val2, 'cause') || !cause1Enumerable && !innerDeepEqual(val1.cause, val2.cause, strict, memos)) { return false; }
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (just a general suggestion without need to follow-up upon): the variable names could be changed in a way that it's clearer what they stand for. E.g., this one could be:
Suggested change
That way it would be easy to understand in the comparison that the entries are meant to be identical.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
kylo5aby
force-pushed
the
assert-error-type-compare
branch
2 times, most recently
from
bd5f30d to
bcf4e54
Compare
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
atlowChemi
reviewed
Comment on lines
247
to
250
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell, this means now we only compare the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
@legendecas PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding an item to the change list in the YAML frontmatter as well? Such as:
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/51805
description: Error cause property is now compared as well.
--->
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
assertDeepAndStrictEqual only accepts two arguments.
| assertDeepAndStrictEqual(e1, new Error('err', { cause: new Error('cause e1') }), AssertionError); | |
| assertDeepAndStrictEqual(e1, new Error('err', { cause: new Error('cause e1') })); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| assertDeepAndStrictEqual(e3, e3duplicate, AssertionError); | |
| assertDeepAndStrictEqual(e3, e3duplicate); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
f93555c to
5f48ab0
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I believe the actual behavior unconditionally compares the errors property regardless of whether the error instance is an AggregateError or not. This could be reworded as
* [`Error`][] names, messages, causes, and errors are always compared, even if these are not enumerable properties.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Resolved. Thanks for the reminder
Sorry, something went wrong.
There was an error while loading. Please reload this page.
5f48ab0 to
7562ac6
Compare
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in c8a4f70 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
PR-URL: #51805 Fixes: #51793 Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: #51805 Fixes: #51793 Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: nodejs#51805 Fixes: nodejs#51793 Reviewed-By: Chengzhong Wu <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
deepStrictEqual and notDeepStrictEqual do not compare Error causes nor AggregateError errors arrays
There was an error while loading. Please reload this page.