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 committed 2017-07-03 16:20:13 +02:00
1 parent 8b2c61c169
commit 1d7414354e
2 files changed
+10 -6

No files matched your search

+1 -1
View File
@@ -527,7 +527,7 @@ function innerThrows(shouldThrow, block, expected, message) {
if (typeof block !== 'function') {
const errors = lazyErrors();
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'block', 'function',
typeof block);
block);
}
if (typeof expected === 'string') {
+9 -5
View File
@@ -669,10 +669,9 @@ try {
{
// Verify that throws() and doesNotThrow() throw on non-function block
const validationFunction = common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
function typeName(value) {
return value === null ? 'null' : typeof value;
}
const testBlockTypeError = (method, block) => {
let threw = true;
@@ -681,7 +680,12 @@ try {
method(block);
threw = false;
} 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);