Skip to content

Commit

Permalink
Update assert.throws from code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Dec 5, 2014
1 parent 28f5c02 commit 523802a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/helpers/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ assert.notSameValue = function (actual, unexpected, message) {
$ERROR(message);
};

assert.throws = function (expectedErrorConstructor, func, message) {
assert.throws = function (expectedErrorConstructor, func) {
if (func === undefined) {
$ERROR('assert.throws requires two arguments: the error constructor and a function to run');
return;
}

try {
func();
} catch (thrown) {
if (typeof thrown !== 'object' || thrown === null) {
$ERROR('Thrown value was not an object!');
return;
}
if (thrown.constructor !== expectedErrorConstructor) {
$ERROR('Expected a ' + expectedErrorConstructor.name + ' but got a ' + thrown.constructor.name);
Expand Down

0 comments on commit 523802a

Please sign in to comment.