Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

Fixes #2893.
  • Loading branch information...
commit 72bc4dcda4cfa99ed064419e40d104bd1b2e0e25 1 parent aa0650f
@koichik koichik authored
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/assert.js
  2. +10 −0 test/simple/test-assert.js
View
4 lib/assert.js
@@ -306,11 +306,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
10 test/simple/test-assert.js
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.