diff --git a/lib/helpers/assert.js b/lib/helpers/assert.js index 1834413..2c1c884 100644 --- a/lib/helpers/assert.js +++ b/lib/helpers/assert.js @@ -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);