diff options
author | Oleg Slobodskoi <oleg008@gmail.com> | 2010-11-27 02:03:31 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-30 04:22:36 +0300 |
commit | 02083412eb3eb673699ef9d3eef04078da8247d5 (patch) | |
tree | 44f900e765603ac273760cc06b4f5aa0fd75d86b /test | |
parent | 86727b15f3f1d33a077e4044991264be74497b37 (diff) |
assert.throws can now accept as RegExp
makes validation of errors more flexible
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-assert.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js index ea270cbcea8..906d96a019f 100644 --- a/test/simple/test-assert.js +++ b/test/simple/test-assert.js @@ -158,3 +158,13 @@ assert.equal(true,threw,'a.doesNotThrow is not catching type matching errors'); assert.throws(function () {assert.ifError(new Error('test error'))}); assert.doesNotThrow(function(){assert.ifError(null)}); assert.doesNotThrow(function(){assert.ifError()}); + +// use a RegExp to validate error message +a.throws(makeBlock(thrower, TypeError), /test/ ); + +// use a fn to validate error object +a.throws(makeBlock(thrower, TypeError), function(err) { + if (!(err instanceof TypeError) || !/test/.test(err)) { + return false; + } +}); |