-
Notifications
You must be signed in to change notification settings - Fork 28.9k
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: deprecate assert.fail partially #18418
Conversation
b990b8a
to
33671e2
Compare
doc/api/assert.md
Outdated
[`Error.captureStackTrace`]). If no arguments are given, the default message | ||
`Failed` will be used. | ||
* `actual` {any} _Deprecated if not used as message (see below)_ | ||
* `expected` {any}_Deprecated (see below)_ |
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.
Nit: space after first _
.
lib/assert.js
Outdated
warned = true; | ||
process.emitWarning( | ||
'assert.fail() with more than one argument is deprecated. ' + | ||
'Please use assert.strictEqual instead or only pass a message.', |
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.
Nit: assert.strictEqual()
for consistency.
doc/api/deprecations.md
Outdated
|
||
Type: Runtime | ||
|
||
Using `assert.fail()` with more than one argument has no benefit over writing a |
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.
Nit: a individual -> an individual.
Comments addressed. |
@@ -406,27 +406,52 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the | |||
## assert.fail(actual, expected[, message[, operator[, stackStartFunction]]]) |
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.
The signature here looks rather confusing, since actual
and expected
looks required here...maybe create another section with assert.fail(message)
, and deprecate this signature while referencing the new one?
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.
Also, that way we can put a deprecated
entry in the YAML so the whole signature would be labeled with deprecated
in the TOC.
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.
I agree that it looks confusing. We just never had such a case before but I agree that this is probably the best way to solve this. I will change it shortly.
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.
Done
doc/api/assert.md
Outdated
* `actual` {any} | ||
* `expected` {any} | ||
* `message` {any} **Default:** `'Failed'` | ||
* `operator` {string} **Default:** '!=' | ||
* `operator` {string} **Default:** '!='_ |
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.
Unnecessary underscore?
doc/api/assert.md
Outdated
@@ -440,21 +465,11 @@ assert.fail(1, 2, new TypeError('need array')); | |||
// TypeError: need array | |||
``` | |||
|
|||
*Note*: In the last two cases `actual`, `expected`, and `operator` have no | |||
*Note*: In the last three cases `actual`, `expected`, and `operator` have no |
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.
Perhaps drop the *:Note*:
part of this now? It's not super necessary.
doc/api/deprecations.md
Outdated
@@ -818,6 +818,15 @@ a future version at which point only authentication tag lengths of 128, 120, | |||
is not included in this list will be considered invalid in compliance with | |||
[NIST SP 800-38D][]. | |||
|
|||
<a id="DEP0XXX"></a> | |||
### DEP0XXX: Using `assert.fail()` with more than one argument. |
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.
s/DEP0XXX/DEP00XX
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.
LGTM with one suggestion
test/parallel/test-assert-fail.js
Outdated
@@ -5,6 +5,12 @@ | |||
const common = require('../common'); | |||
const assert = require('assert'); | |||
|
|||
common.expectWarning( |
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.
Can you put the tests with the valid signatures to another file?
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.
Done
0c6d14a
to
34143dd
Compare
Rebased due to conflicts and while doing so I also rewrote |
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.
LGTM but needs a rebase
34143dd
to
adc742e
Compare
Using `assert.fail()` with more than one argument is not intuitive to use and has no benefit over using a message on its own. Therefore this introduces a runtime deprecation in case it is used in that way.
adc742e
to
bf4ac0c
Compare
Landed in 70dcacd |
Using `assert.fail()` with more than one argument is not intuitive to use and has no benefit over using a message on its own. Therefore this introduces a runtime deprecation in case it is used in that way. PR-URL: nodejs#18418 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Using `assert.fail()` with more than one argument is not intuitive to use and has no benefit over using a message on its own. Therefore this introduces a runtime deprecation in case it is used in that way. PR-URL: nodejs#18418 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Using
assert.fail()
with more than one argument is not intuitiveto use and has no benefit over using a message on its own.
Therefore this introduces a runtime deprecation in case it is used
in that way.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
assert