| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This should be ===.
Sorry, something went wrong.
There was a problem hiding this comment.
Actually, since this is loose equality, shouldn't it stay as ==? The current assert() function uses == as well (https://github.com/nodejs/node/blob/master/lib/assert.js#L78)
Sorry, something went wrong.
There was a problem hiding this comment.
@evanlucas if I'm not wrong there only assert.strictEqual() is currently used in this file.
Edit: nvm didn't see https://github.com/nodejs/node/pull/15002/files#diff-5a3344c263a73c663dd1cfcb91880fd7R70. Yes it's better to keep ==, ignore my comment.
Sorry, something went wrong.
There was a problem hiding this comment.
IMHO since this is an internal module assertions should be made in /test/, so there's no need for runtime assertions at all.
Sorry, something went wrong.
|
@nodejs/collaborators ... ping! |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. I'm only a bit hesitant about exporting the constants.
Sorry, something went wrong.
|
As am I, to be honest, I'm not convinced that it will be all that useful. |
Sorry, something went wrong.
There was a problem hiding this comment.
Not too worried about exporting the constants.
Sorry, something went wrong.
There was a problem hiding this comment.
IMHO assert should be removed for this module
Sorry, something went wrong.
There was a problem hiding this comment.
IMHO since this is an internal module assertions should be made in /test/, so there's no need for runtime assertions at all.
Sorry, something went wrong.
|
@refack... that's certainly a valid argument also :-) |
Sorry, something went wrong.
|
I agree with @refack that using AssertionErrors here is not required and I would actually like to get rid of all asserts in /lib. I am also not convinced about the export of the constants. |
Sorry, something went wrong.
|
Looking at it further, I don't think we should remove the asserts. In particular, if someone ends up passing something like new errors.Error(), the result is a really odd code. Just as we have CHECKs at the C/C++ layer, we should have some basic checks at the js layer to keep from footgunning ourselves. I will drop the commit that exports the constants tho. @refack ... let's look at the possibility of pulling the asserts separately. |
Sorry, something went wrong.
|
Well, I did not mean to get rid of the checks but I think it is good enough if we use if (truthy) { fail }. But probably it is fine to just stick to the asserts as they are. Another note - as I pointed out in #14350, this is not really a alternative to it as it tries to solve something different. |
Sorry, something went wrong.
IMHO assertions are valid when dealing with userland inputs. For an internal (and fairly simple) construct, coverage by unit tests should be sufficient. But anyway I'm removing my objection. |
Sorry, something went wrong.
Sorry, something went wrong.
|
@jasnell do you mind changing the assert name to something else e.g. "internalAssert"? Otherwise I think it is a bit confusing that it is not the "real" assert module and no other functions are available. |
Sorry, something went wrong.
I just had the same though 🤔 |
Sorry, something went wrong.
|
Updated with the function renamed and a test fixed. |
Sorry, something went wrong.
Sorry, something went wrong.
PR-URL: #15002 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#15002 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
|
This will need to be backported for 8.x |
Sorry, something went wrong.
PR-URL: nodejs#15002 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #15002 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
| Back | FazBrowse Home | New Git URL |
An alternative to #14350 ... eliminates the circular dependency with the assert module.
Also, export the defined error keys as constants. Some have said this makes it easier but I'm not fully convinced.
Checklist
Affected core subsystem(s)
errors