-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: assert.throws('string', TypeError, 'whatever') passes when it shouldn't #275
Comments
The third argument isn't supposed to be validated is it? The documentation doesn't seem to imply that it should. To validate the exception message, the second argument should be a regex or function. The third argument should be included in the error message though, right? That doesn't seem to be happening. |
The third argument is the message to put in the |
Checking the thrown exception message would be to give a string as the second argument, rather than a constructor (you can also provide a RegExp object as the second argument). |
I don't think strings are supported as the second arguments. Is there a specific reason that the |
Alright, seems I was wrong about the third argument. Let me rephrase: |
@bnoordhuis +1 on throwing on bad input. I'll work on this. |
what if the assert library were just changed to eval() if the first argument is a string? mjsunit does it like this, it's convenient :> (as suggested above, I guess) |
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>
Closed in 14dc917 |
Think I like the v8 behavior better there |
From here:
The text was updated successfully, but these errors were encountered: