assert: make sure throws is able to handle primitives#20482
Closed
BridgeAR wants to merge 1 commit intonodejs:masterfrom
Closed
assert: make sure throws is able to handle primitives#20482BridgeAR wants to merge 1 commit intonodejs:masterfrom
BridgeAR wants to merge 1 commit intonodejs:masterfrom
Conversation
Member
Author
Member
Author
|
|
c3026d9 to
6b1f886
Compare
Member
Author
|
New CI https://ci.nodejs.org/job/node-test-pull-request/14696/ @nodejs/testing PTAL |
Member
|
As I understand it, this makes |
Member
Author
|
@addaleax that is indeed an edge case and actually a side effect of this fix. It is meant to fix: assert.throws(() => { throw 4; }, { message: '4' })
TypeError: Cannot use 'in' operator to search for 'message' in 4
at compareExceptionKey (assert.js:374:13)I will work around it to prevent it from being semver-major. |
Member
Author
Member
Author
|
@nodejs/collaborators PTAL |
jasnell
approved these changes
May 9, 2018
targos
approved these changes
May 10, 2018
This fixes some possible issues with `assert.throws` in combination with an validation object. It will now properly handle primitive values being thrown as error. It also makes sure the `generatedMessage` property is properly set if `assert.throws` is used in combination with an validation object and improves the error performance in such cases by only creating the error once.
ee4907a to
34b4818
Compare
Member
Author
|
Rebased due to conflicts. CI before landing: https://ci.nodejs.org/job/node-test-pull-request/14781/ |
BridgeAR
added a commit
to BridgeAR/node
that referenced
this pull request
May 10, 2018
This fixes some possible issues with `assert.throws` and `assert.rejects` in combination with an validation object. It will now properly handle primitive values being thrown as error. It also makes sure the `generatedMessage` property is properly set if `assert.throws` or `assert.rejects` is used in combination with an validation object and improves the error performance in such cases by only creating the error once. In addition it will fix detecting regular expressions from a different context such as n-api that are passed through as validator for `assert.throws` or `assert.rejects`. Until now those were not tested. PR-URL: nodejs#20482 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Member
Author
|
Landed in 560925f |
targos
pushed a commit
that referenced
this pull request
May 12, 2018
This fixes some possible issues with `assert.throws` and `assert.rejects` in combination with an validation object. It will now properly handle primitive values being thrown as error. It also makes sure the `generatedMessage` property is properly set if `assert.throws` or `assert.rejects` is used in combination with an validation object and improves the error performance in such cases by only creating the error once. In addition it will fix detecting regular expressions from a different context such as n-api that are passed through as validator for `assert.throws` or `assert.rejects`. Until now those were not tested. PR-URL: #20482 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes some possible issues with
assert.throwsin combinationwith an validation object. It will now properly handle primitive
values being thrown as error.
It also makes sure the
generatedMessageproperty is properly setif
assert.throwsis used in combination with an validation objectand improves the error performance in such cases by only creating
the error once.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes