assert: throw when block is not a function#308
assert: throw when block is not a function#308cjihrig wants to merge 1 commit intonodejs:v1.xfrom cjihrig:throws
Conversation
Currently, anything passed as the block argument to throws() and doesNotThrow() is interpreted as a function, which can lead to unexpected results. This commit checks the type of block, and throws a TypeError if it is not a function.
|
LGTM |
|
@bnoordhuis should I land this before or after 1.0.0? It's a small behavior change. Also, how do you feel about this somewhat related PR - nodejs/node-v0.x-archive#8734 |
|
I think this PR can land now, the current behavior is never the desired one. Worst case, it exposes bugs in people's test suites. nodejs/node-v0.x-archive#8734 looks reasonable at a glance but perhaps needs more careful inspection. I could see it cause regressions when you .deepEqual() on very large objects, for example. |
Could you elaborate? Does |
|
It works but it can be very slow. I suppose it's only an issue when the assert fails. |
Currently, anything passed as the block argument to throws() and doesNotThrow() is interpreted as a function, which can lead to unexpected results. This commit checks the type of block, and throws a TypeError if it is not a function. Fixes: #275 PR-URL: #308 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
|
Landed in 14dc917 |
Currently, anything passed as the
blockargument tothrows()anddoesNotThrow()is interpreted as a function, which can lead to unexpected results. This commit checks the type ofblock, and throws aTypeErrorif it is not a function.We might want to hold off until after 1.0.0, not sure. Closes #275.
R=@bnoordhuis