Skip to content

Commit

Permalink
squash: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Feb 10, 2017
1 parent 9df45db commit 567284f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ function _throws(shouldThrow, block, expected, message) {

actual = _tryBlock(block);

message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '');
message = (expected && expected.name ? ' (' + expected.name + ')' : '') +
(message ? ': ' + message : '.');

if (shouldThrow && !actual) {
fail(actual, expected, 'Missing expected exception' + message);
Expand Down
23 changes: 23 additions & 0 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,29 @@ a.throws(makeBlock(a.deepEqual, args, []));
a.doesNotThrow(makeBlock(a.deepEqual, someArgs, sameArgs));
}

// check messages from assert.throws()
{
assert.throws(
() => { a.throws(() => {}); },
/^AssertionError: Missing expected exception\.$/
);

assert.throws(
() => { a.throws(() => {}, TypeError); },
/^AssertionError: Missing expected exception \(TypeError\)\.$/
);

assert.throws(
() => { a.throws(() => {}, 'fhqwhgads'); },
/^AssertionError: Missing expected exception: fhqwhgads$/
);

assert.throws(
() => { a.throws(() => {}, TypeError, 'fhqwhgads'); },
/^AssertionError: Missing expected exception \(TypeError\): fhqwhgads$/
);
}

const circular = {y: 1};
circular.x = circular;

Expand Down

0 comments on commit 567284f

Please sign in to comment.