This file contains 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
/** | |
* Checks that the given expression throws an exception of the expected type, with an optional message. | |
* | |
* @example raises( function() { return foo.bar; }, "TypeError", "invalid property access raises TypeError exception" ); | |
* | |
* @param Function expression | |
* @param String expected exception type | |
* @param String message (optional) | |
*/ | |
function raises(expression, expected, message) { | |
try { | |
push(false, expression(), expected, message); | |
} catch(ex) { | |
console.log(message, ex.name, ex); | |
push(ex.name == expected, ex.name, expected, message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment