Permalink
Browse files

assert: fix throws() throws an error without message property

Fixes #2893.
  • Loading branch information...
koichik committed Mar 24, 2012
1 parent 4515987 commit deba244d9a915fa0d1b923b3ddba46c03ba3c7cd
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/assert.js
  2. +10 −0 test/simple/test-assert.js
View
@@ -308,11 +308,11 @@ function _throws(shouldThrow, block, expected, message) {
(message ? ' ' + message : '.');
if (shouldThrow && !actual) {
- fail('Missing expected exception' + message);
+ fail(actual, expected, 'Missing expected exception' + message);
}
if (!shouldThrow && expectedException(actual, expected)) {
- fail('Got unwanted exception' + message);
+ fail(actual, expected, 'Got unwanted exception' + message);
}
if ((shouldThrow && actual && expected &&
View
@@ -283,3 +283,13 @@ testAssertionMessage({a: undefined, b: null}, '{"a":"undefined","b":null}');
testAssertionMessage({a: NaN, b: Infinity, c: -Infinity},
'{"a":"NaN","b":"Infinity","c":"-Infinity"}');
+// #2893
+try {
+ assert.throws(function () {
+ assert.ifError(null);
+ });
+} catch (e) {
+ threw = true;
+ assert.equal(e.message, 'Missing expected exception..');
+}
+assert.ok(threw);

0 comments on commit deba244

Please sign in to comment.