diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-09-08 02:30:07 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-09-11 23:45:07 +0200 |
commit | b5430d782d1c00ecdc421ad28b4f6c5ff62ba972 (patch) | |
tree | b4bb8637e2dbab8bc0455799ba2301346486623a /test/parallel | |
parent | e4dd213516afdff64063682e0d0d46c58499a9f3 (diff) | |
download | android-node-v8-b5430d782d1c00ecdc421ad28b4f6c5ff62ba972.tar.gz android-node-v8-b5430d782d1c00ecdc421ad28b4f6c5ff62ba972.tar.bz2 android-node-v8-b5430d782d1c00ecdc421ad28b4f6c5ff62ba972.zip |
assert: align argument names
This makes sure the documented argument names and the ones thrown
in errors is aligned with the actual argument name.
PR-URL: https://github.com/nodejs/node/pull/22760
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Diffstat (limited to 'test/parallel')
-rw-r--r-- | test/parallel/test-assert-async.js | 8 | ||||
-rw-r--r-- | test/parallel/test-assert.js | 10 | ||||
-rw-r--r-- | test/parallel/test-file-write-stream3.js | 4 | ||||
-rw-r--r-- | test/parallel/test-net-connect-options-port.js | 85 | ||||
-rw-r--r-- | test/parallel/test-net-server-listen-options.js | 6 |
5 files changed, 52 insertions, 61 deletions
diff --git a/test/parallel/test-assert-async.js b/test/parallel/test-assert-async.js index 30c9a741c6..f148c7e3d8 100644 --- a/test/parallel/test-assert-async.js +++ b/test/parallel/test-assert-async.js @@ -41,7 +41,7 @@ const promises = []; name: 'TypeError [ERR_INVALID_RETURN_VALUE]', code: 'ERR_INVALID_RETURN_VALUE', message: 'Expected instance of Promise to be returned ' + - 'from the "block" function but got type undefined.' + 'from the "promiseFn" function but got type undefined.' })); promise = assert.rejects(Promise.resolve(), common.mustNotCall()); @@ -62,7 +62,7 @@ promises.push(assert.rejects( assert.rejects('fail', {}), { code: 'ERR_INVALID_ARG_TYPE', - message: 'The "block" argument must be one of type ' + + message: 'The "promiseFn" argument must be one of type ' + 'Function or Promise. Received type string' } )); @@ -73,7 +73,7 @@ promises.push(assert.rejects( const promise = assert.doesNotReject(() => new Map(), common.mustNotCall()); promises.push(assert.rejects(promise, { message: 'Expected instance of Promise to be returned ' + - 'from the "block" function but got instance of Map.', + 'from the "promiseFn" function but got instance of Map.', code: 'ERR_INVALID_RETURN_VALUE', name: 'TypeError [ERR_INVALID_RETURN_VALUE]' })); @@ -116,7 +116,7 @@ promises.push(assert.rejects( assert.doesNotReject(123), { code: 'ERR_INVALID_ARG_TYPE', - message: 'The "block" argument must be one of type ' + + message: 'The "promiseFn" argument must be one of type ' + 'Function or Promise. Received type number' } )); diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 72ba7d2443..bdbde655d7 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -348,15 +348,15 @@ try { } { - // Verify that throws() and doesNotThrow() throw on non-function block. - const testBlockTypeError = (method, block) => { + // Verify that throws() and doesNotThrow() throw on non-functions. + const testBlockTypeError = (method, fn) => { common.expectsError( - () => method(block), + () => method(fn), { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "block" argument must be of type Function. Received ' + - `type ${typeof block}` + message: 'The "fn" argument must be of type Function. Received ' + + `type ${typeof fn}` } ); }; diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js index 6bb64e6092..db16318a5c 100644 --- a/test/parallel/test-file-write-stream3.js +++ b/test/parallel/test-file-write-stream3.js @@ -178,7 +178,7 @@ function run_test_3() { const run_test_4 = common.mustCall(function() { // Error: start must be >= zero - const block = () => { + const fn = () => { fs.createWriteStream(filepath, { start: -5, flags: 'r+' }); }; const err = { @@ -187,7 +187,7 @@ const run_test_4 = common.mustCall(function() { 'It must be >= 0. Received {start: -5}', type: RangeError }; - common.expectsError(block, err); + common.expectsError(fn, err); }); run_test_1(); diff --git a/test/parallel/test-net-connect-options-port.js b/test/parallel/test-net-connect-options-port.js index db7a123f77..afdfc2ac61 100644 --- a/test/parallel/test-net-connect-options-port.js +++ b/test/parallel/test-net-connect-options-port.js @@ -62,8 +62,8 @@ const net = require('net'); const hints = (dns.ADDRCONFIG | dns.V4MAPPED) + 42; const hintOptBlocks = doConnect([{ hints }], () => common.mustNotCall()); - for (const block of hintOptBlocks) { - common.expectsError(block, { + for (const fn of hintOptBlocks) { + common.expectsError(fn, { code: 'ERR_INVALID_OPT_VALUE', type: TypeError, message: /The value "\d+" is invalid for option "hints"/ @@ -136,38 +136,31 @@ function doConnect(args, getCb) { function syncFailToConnect(port, assertErr, optOnly) { if (!optOnly) { // connect(port, cb) and connect(port) - const portArgBlocks = doConnect([port], () => common.mustNotCall()); - for (const block of portArgBlocks) { - assert.throws(block, - assertErr, - `${block.name}(${port})`); + const portArgFunctions = doConnect([port], () => common.mustNotCall()); + for (const fn of portArgFunctions) { + assert.throws(fn, assertErr, `${fn.name}(${port})`); } // connect(port, host, cb) and connect(port, host) - const portHostArgBlocks = doConnect([port, 'localhost'], - () => common.mustNotCall()); - for (const block of portHostArgBlocks) { - assert.throws(block, - assertErr, - `${block.name}(${port}, 'localhost')`); + const portHostArgFunctions = doConnect([port, 'localhost'], + () => common.mustNotCall()); + for (const fn of portHostArgFunctions) { + assert.throws(fn, assertErr, `${fn.name}(${port}, 'localhost')`); } } // connect({port}, cb) and connect({port}) - const portOptBlocks = doConnect([{ port }], - () => common.mustNotCall()); - for (const block of portOptBlocks) { - assert.throws(block, - assertErr, - `${block.name}({port: ${port}})`); + const portOptFunctions = doConnect([{ port }], () => common.mustNotCall()); + for (const fn of portOptFunctions) { + assert.throws(fn, assertErr, `${fn.name}({port: ${port}})`); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }], - () => common.mustNotCall()); - for (const block of portHostOptBlocks) { - assert.throws(block, + const portHostOptFunctions = doConnect([{ port: port, host: 'localhost' }], + () => common.mustNotCall()); + for (const fn of portHostOptFunctions) { + assert.throws(fn, assertErr, - `${block.name}({port: ${port}, host: 'localhost'})`); + `${fn.name}({port: ${port}, host: 'localhost'})`); } } @@ -175,28 +168,27 @@ function canConnect(port) { const noop = () => common.mustCall(); // connect(port, cb) and connect(port) - const portArgBlocks = doConnect([port], noop); - for (const block of portArgBlocks) { - block(); + const portArgFunctions = doConnect([port], noop); + for (const fn of portArgFunctions) { + fn(); } // connect(port, host, cb) and connect(port, host) - const portHostArgBlocks = doConnect([port, 'localhost'], noop); - for (const block of portHostArgBlocks) { - block(); + const portHostArgFunctions = doConnect([port, 'localhost'], noop); + for (const fn of portHostArgFunctions) { + fn(); } // connect({port}, cb) and connect({port}) - const portOptBlocks = doConnect([{ port }], noop); - for (const block of portOptBlocks) { - block(); + const portOptFunctions = doConnect([{ port }], noop); + for (const fn of portOptFunctions) { + fn(); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }], - noop); - for (const block of portHostOptBlocks) { - block(); + const portHostOptFns = doConnect([{ port, host: 'localhost' }], noop); + for (const fn of portHostOptFns) { + fn(); } } @@ -208,21 +200,20 @@ function asyncFailToConnect(port) { const dont = () => common.mustNotCall(); // connect(port, cb) and connect(port) - const portArgBlocks = doConnect([port], dont); - for (const block of portArgBlocks) { - block().on('error', onError()); + const portArgFunctions = doConnect([port], dont); + for (const fn of portArgFunctions) { + fn().on('error', onError()); } // connect({port}, cb) and connect({port}) - const portOptBlocks = doConnect([{ port }], dont); - for (const block of portOptBlocks) { - block().on('error', onError()); + const portOptFunctions = doConnect([{ port }], dont); + for (const fn of portOptFunctions) { + fn().on('error', onError()); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }], - dont); - for (const block of portHostOptBlocks) { - block().on('error', onError()); + const portHostOptFns = doConnect([{ port, host: 'localhost' }], dont); + for (const fn of portHostOptFns) { + fn().on('error', onError()); } } diff --git a/test/parallel/test-net-server-listen-options.js b/test/parallel/test-net-server-listen-options.js index 41cc07d40d..6c783c95dc 100644 --- a/test/parallel/test-net-server-listen-options.js +++ b/test/parallel/test-net-server-listen-options.js @@ -54,20 +54,20 @@ const listenOnPort = [ { function shouldFailToListen(options) { - const block = () => { + const fn = () => { net.createServer().listen(options, common.mustNotCall()); }; if (typeof options === 'object' && !(('port' in options) || ('path' in options))) { - common.expectsError(block, + common.expectsError(fn, { code: 'ERR_INVALID_ARG_VALUE', type: TypeError, message: /^The argument 'options' must have the property "port" or "path"\. Received .+$/, }); } else { - common.expectsError(block, + common.expectsError(fn, { code: 'ERR_INVALID_OPT_VALUE', type: TypeError, |