-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: restore TypeError if no arguments #12843
Conversation
I think I'd rather keep the default and fix the message so that it's more helpful in the default case |
There is no such thing as a "default case" for an assertion. By definition, an assertion needs to be about something specific. A default argument here isn't fulfilling some unmet need. It's just extra surface area we don't need. Although this does make me realize I should add a test... |
Ok. I'm not going to object to the change over a simple personal preference ;-) ... the code LGTM |
In Node 7.x, calling `throw new assert.AssertionError()` resulted in a TypeError. In current master, the same call does not result in an error but, due to the default option, it results in uninformative output ("undefined undefined undefined"). This change removes the default argument, restoring a TypeError if there is no argument. This also will restore our test coverage to 100%. (The default argument is not tested in our current test suite.)
a6ea00b
to
078ff1c
Compare
}); | ||
{ | ||
// bad args to AssertionError constructor should throw TypeError | ||
const args = [1, true, false, '', null, Infinity, Symbol('test'), undefined]; |
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.
If you've went to the trouble of making it more readable, why not call it badArgs
or invalidArgs
. I've seen the line is 77 chars long, but maybe... Maybe just invalids
or bad
?
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.
nonArgs
In Node 7.x, calling `throw new assert.AssertionError()` resulted in a TypeError. In current master, the same call does not result in an error but, due to the default option, it results in uninformative output ("undefined undefined undefined"). This change removes the default argument, restoring a TypeError if there is no argument. This also will restore our test coverage to 100%. (The default argument is not tested in our current test suite.) PR-URL: nodejs#12843 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in f6247a9 |
In Node 7.x, calling `throw new assert.AssertionError()` resulted in a TypeError. In current master, the same call does not result in an error but, due to the default option, it results in uninformative output ("undefined undefined undefined"). This change removes the default argument, restoring a TypeError if there is no argument. This also will restore our test coverage to 100%. (The default argument is not tested in our current test suite.) PR-URL: nodejs#12843 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
I think this means that this isn't needed on v6.x, correct me if I'm wrong @Trott |
I think that's right. |
In Node 7.x, calling
throw new assert.AssertionError()
resulted in aTypeError.
In current master, the same call does not result in an error but, due to
the default option, it results in uninformative output ("undefined
undefined undefined").
This change removes the default argument, restoring a TypeError if there
is no argument. This also will restore our test coverage to 100%. (The
default argument is not tested in our current test suite.)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
assert