Skip to content

assert: validate the block return type - #19886

Closed
BridgeAR wants to merge 2 commits into
nodejs:masterfrom
BridgeAR:stricter-assert-rejects
Closed

assert: validate the block return type#19886
BridgeAR wants to merge 2 commits into
nodejs:masterfrom
BridgeAR:stricter-assert-rejects

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

This makes sure the returned value when calling block is actually
of type promise in case assert.rejects or assert.doesNotReject
is called.

This currently relies on #19885 and I am going to rebase as soon as that lands / changes. Marking as blocked in the meanwhile.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BridgeARBridgeAR added the blocked PRs that are blocked by other issues or PRs. label Apr 9, 2018
@nodejs-github-botnodejs-github-bot added assert Issues and PRs related to the assert subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. tools Issues and PRs related to the tools directory. labels Apr 9, 2018
Comment thread.eslintrc.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an object

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change from #19885 that I plan on removing in here as soon as that lands. I already fixed that in there though.

@BridgeARBridgeAR mentioned this pull request Apr 12, 2018
4 tasks
This makes sure the returned value when calling `block` is actually
of type promise in case `assert.rejects` or `assert.doesNotReject`
is called.
@BridgeAR
BridgeARforce-pushed the stricter-assert-rejects branch from 8fdc532 to 386f664CompareApril 16, 2018 02:14
@BridgeARBridgeAR removed the blocked PRs that are blocked by other issues or PRs. label Apr 16, 2018
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Rebased. This is unblocked and should now be looked at.

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@targos PTAL

Comment threaddoc/api/assert.md Outdated
rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases
without checking the error handler.

If `block` is a function and it does not return a promise, an

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this redundant with the previous paragraph?

Comment threaddoc/api/errors.md Outdated
<a id="ERR_INVALID_RETURN_VALUE"></a>
### ERR_INVALID_RETURN_VALUE

Thrown in case a function option does not return a expected value on execution.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: an expected value

Comment threaddoc/api/assert.md Outdated
`assert.doesNotReject()` will return a rejected Promise with that error. If the
function does not return a promise, `assert.doesNotReject()` will return a
rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases
without checking the error handler.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence fragment seems a bit unexpected. Should we add a verb to it?

Comment threaddoc/api/assert.md Outdated
`assert.rejects()` will return a rejected Promise with that error without
`assert.rejects()` will return a rejected Promise with that error. If the
function does not return a promise, `assert.rejects()` will return a rejected
Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases without

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@vsemozhetbyt@targos PTAL. This should be ready to land otherwise.

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 19, 2018

@vsemozhetbytvsemozhetbyt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs LGTM)

BridgeAR added a commit to BridgeAR/node that referenced this pull request Apr 19, 2018
This makes sure the returned value when calling `block` is actually
of type promise in case `assert.rejects` or `assert.doesNotReject`
is called.
PR-URL: nodejs#19886
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Landed in 7007eee

jasnell pushed a commit that referenced this pull request Apr 20, 2018
This makes sure the returned value when calling `block` is actually
of type promise in case `assert.rejects` or `assert.doesNotReject`
is called.
PR-URL: #19886
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@BridgeAR
BridgeAR deleted the stricter-assert-rejects branch January 20, 2020 11:28
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assertIssues and PRs related to the assert subsystem.author readyPRs that have at least one approval, no pending requests for changes, and a CI started.errorsIssues and PRs related to JavaScript errors originated in Node.js core.toolsIssues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@BridgeAR@jasnell@targos@vsemozhetbyt@nodejs-github-bot