assert: fix incorrect use of ERR_INVALID_ARG_TYPE

PR-URL: https://github.com/nodejs/node/pull/14011
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Tobias Nießen 2017-06-30 21:30:23 +02:00
parent 8b2c61c169
commit 1d7414354e
2 changed files with 10 additions and 6 deletions

View File

@ -527,7 +527,7 @@ function innerThrows(shouldThrow, block, expected, message) {
if (typeof block !== 'function') { if (typeof block !== 'function') {
const errors = lazyErrors(); const errors = lazyErrors();
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'block', 'function', throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'block', 'function',
typeof block); block);
} }
if (typeof expected === 'string') { if (typeof expected === 'string') {

View File

@ -669,10 +669,9 @@ try {
{ {
// Verify that throws() and doesNotThrow() throw on non-function block // Verify that throws() and doesNotThrow() throw on non-function block
const validationFunction = common.expectsError({ function typeName(value) {
code: 'ERR_INVALID_ARG_TYPE', return value === null ? 'null' : typeof value;
type: TypeError }
});
const testBlockTypeError = (method, block) => { const testBlockTypeError = (method, block) => {
let threw = true; let threw = true;
@ -681,7 +680,12 @@ try {
method(block); method(block);
threw = false; threw = false;
} catch (e) { } catch (e) {
validationFunction(e); common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "block" argument must be of type function. Received ' +
'type ' + typeName(block)
})(e);
} }
assert.ok(threw); assert.ok(threw);