| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This makes sure `assert.fail()` contains an operator instead of being undefined. On top of that it also fixes the `err.generatedMessage` property. Before, it was not always set correct.
|
@BridgeAR build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/792/pipeline |
Sorry, something went wrong.
|
semver-major in case someone is adding a property called generatedMessage to their assertion errors? Or is that too far-fetched? |
Sorry, something went wrong.
|
Is there a reason to expose generatedMessage? If there's no reason, to expose it then should we hide it? If there is a reason to expose it, should we document it? |
Sorry, something went wrong.
|
@Trott the generatedMessage property was also present before. It was just not set correct all the time. It is also already documented on the AssertionError class. |
Sorry, something went wrong.
|
PTAL @nodejs/util |
Sorry, something went wrong.
|
@nodejs/testing |
Sorry, something went wrong.
|
I see that operator can be 'throws' and 'doesNotThrow'. Is that a relatively recent addition? I was under the impression that operator was always a JavaScript comparison operator like !==. A function name is surprising to me. I'm guessing it's too late to prevent such a change from ending up in a release. (Maybe I'm wrong and 'throws' has been a legit value for operator for years?) I bring this up because I'd rather operator be undefined than fail unless there's a compelling reason to make it the function name sometimes but not all the time. That just seems odd to me. But my argument there is less compelling as we've already started going down this road apparently. |
Sorry, something went wrong.
|
@Trott I am not sure anymore since when that is the case. I think since v8 or v9. Using e.g., === would have been wrong as that is not the actual used comparison. That is why they changed to the function name. Only the loose equal checks contain == and != as operator, plus assert.ok() and partially assert.fail(). Since we filter the function name from the stack trace, it's good to know what function actually triggered the assertion. That's also why they changed to the function name and why I added it here as well. |
Sorry, something went wrong.
|
@BridgeAR Thanks. Just to be clear: Not objecting. Just surprised. :-D |
Sorry, something went wrong.
|
PTAL this could use some reviews. |
Sorry, something went wrong.
| expected, | ||
| message, | ||
| operator, | ||
| operator: operator || 'fail', |
There was a problem hiding this comment.
Does Node have a consistent way of checking for optional params or default params?
In this case the falsey check means that users can't specify it as null or "".
Sorry, something went wrong.
There was a problem hiding this comment.
No, it's often mixed and fasly values are often set to a default while in other cases only undefined is set to a default.
Sorry, something went wrong.
There was a problem hiding this comment.
This method has a mix of deprecated/legacy and new/different functionality. Would moving the operator juggle into a argLength < 2 branch with the other argLen checks be doable? That way it touches less of the overlapping code paths.
Sorry, something went wrong.
There was a problem hiding this comment.
That was done on purpose since I believe it is best to just properly do this for all cases.
Shall I maybe change the check to: operator === undefined ? 'fail' : operator?
Sorry, something went wrong.
|
PTAL |
Sorry, something went wrong.
|
|
||
| innerFail({ | ||
| if (message instanceof Error) throw message; | ||
|
|
There was a problem hiding this comment.
☝️ Should use the util for isError (internal reference) for this since it avoids the error of errors from other realms.
Sorry, something went wrong.
There was a problem hiding this comment.
Only changing this here is likely not the best way. It would have to be changed throughout assert in total or not at all. It is also sad that the util function is not a safe check as the Symbol.toStringTag could be set and isError would happily return true in some weird cases.
Sorry, something went wrong.
There was a problem hiding this comment.
Only changing this here is likely not the best way.
Ah, didn't know this was consistent with the rest of assert. A follow up would be best.
It is also sad that the util function is not a safe check as the Symbol.toStringTag could be set and isError would happily return true in some weird cases.
Oh I thought the new isNativeError was more robust.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I missed the isNativeError somehow. We have multiple places in core where we should likely switch to this check.
Sorry, something went wrong.
|
PTAL |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Sorry, something went wrong.
This makes sure `assert.fail()` contains an operator instead of being undefined. On top of that it also fixes the `err.generatedMessage` property. Before, it was not always set correct. PR-URL: nodejs#22694 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This makes sure `assert.fail()` contains an operator instead of being undefined. On top of that it also fixes the `err.generatedMessage` property. Before, it was not always set correct. PR-URL: #22694 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This makes sure `assert.fail()` contains an operator instead of being undefined. On top of that it also fixes the `err.generatedMessage` property. Before, it was not always set correct. PR-URL: #22694 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This makes sure `assert.fail()` contains an operator instead of being undefined. On top of that it also fixes the `err.generatedMessage` property. Before, it was not always set correct. PR-URL: #22694 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
| Back | FazBrowse Home | New Git URL |
This makes sure assert.fail() contains an operator instead of being
undefined.
On top of that it also fixes the err.generatedMessage property.
Before, it was not always set correct.
Checklist