assert: make sure throws is able to handle primitives by BridgeAR · Pull Request #20482 · nodejs/node

@nodejs-github-bot added the assert

Issues and PRs related to the assert subsystem.

label

May 2, 2018

@vsemozhetbyt vsemozhetbyt added the author ready

PRs that have at least one approval, no pending requests for changes, and a CI started.

label

May 9, 2018

@BridgeAR

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.

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>

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>