assert: fix misformatted error message#11254
Conversation
|
Technically My thinking is that this doesn't violate the Locked API because it's a bug fix, even if we have a policy (at least at this time) to treat this particular type of bug fix like it's semver major. But a "sorry, semver major is semver major, deal with it" approach also makes sense. (In which case, I might see if there's a general sentiment to unlock the API but that's another conversation.) |
|
LGTM, and definitely seems related to #11200. |
lib/assert.js
Outdated
There was a problem hiding this comment.
shouldn't this end with . when message is truthy?
(message ? ` ${message}.` : '');There was a problem hiding this comment.
Yes, unless message is expected to already end with ., so ¯\(ツ)/¯. And there should also be a : rather than . after expected if message is truthy.
Thinking about this some more and looking at the uses, I wonder if the thing to do is get rid of all the logic for appending . in the first place. Nothing else appends .. And this mostly only seems to do it wrong!
Current master results in messages like this:
AssertionError: Missing expected exception..
AssertionError: Missing expected exception. foo bar bazwat?
Compare to assert.strictEqual() which does not append .:
AssertionError: 'a' === 'b'
AssertionError: foo bar bazThere was a problem hiding this comment.
@lpinca OK, I just pushed some improvements based on your comment. PTAL
Before: `Missing expected exception..` Afer: `Missing expected exception.`
This also makes sense imo, I think most error messages don't use |
|
|
Before: `Missing expected exception..` Afer: `Missing expected exception.` PR-URL: nodejs#11254 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
|
Landed in 0af4183 |
Before:
Missing expected exception..Afer:
Missing expected exception.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
assert