assert: fix misformatted error message
Before: `Missing expected exception..` Afer: `Missing expected exception.` PR-URL: https://github.com/nodejs/node/pull/11254 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
parent
4b8b7e9d2b
commit
0af41834f1
@ -341,8 +341,8 @@ function _throws(shouldThrow, block, expected, message) {
|
|||||||
|
|
||||||
actual = _tryBlock(block);
|
actual = _tryBlock(block);
|
||||||
|
|
||||||
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
message = (expected && expected.name ? ' (' + expected.name + ')' : '') +
|
||||||
(message ? ' ' + message : '.');
|
(message ? ': ' + message : '.');
|
||||||
|
|
||||||
if (shouldThrow && !actual) {
|
if (shouldThrow && !actual) {
|
||||||
fail(actual, expected, 'Missing expected exception' + message);
|
fail(actual, expected, 'Missing expected exception' + message);
|
||||||
|
@ -490,6 +490,29 @@ a.throws(makeBlock(a.deepEqual, args, []));
|
|||||||
a.doesNotThrow(makeBlock(a.deepEqual, someArgs, sameArgs));
|
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};
|
const circular = {y: 1};
|
||||||
circular.x = circular;
|
circular.x = circular;
|
||||||
|
|
||||||
@ -535,7 +558,7 @@ testAssertionMessage({a: NaN, b: Infinity, c: -Infinity},
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
threw = true;
|
threw = true;
|
||||||
assert.strictEqual(e.message, 'Missing expected exception..');
|
assert.strictEqual(e.message, 'Missing expected exception.');
|
||||||
}
|
}
|
||||||
assert.ok(threw);
|
assert.ok(threw);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user