diff options
author | Weijia Wang <381152119@qq.com> | 2017-10-28 17:39:55 +0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-11-12 11:04:06 -0800 |
commit | e22b8d0c46728ebdaf64176191ffa2bdd0f56be9 (patch) | |
tree | 7b5c9624490d67fc0c8bff2413e7a27e9f93bbbc /test | |
parent | e0113ab5e0e2b329668fa7d744fac3bfe8b95935 (diff) | |
download | node-new-e22b8d0c46728ebdaf64176191ffa2bdd0f56be9.tar.gz |
lib: improve the usage of TypeError[INVALID_ARG_TYPE]
The initials of expected in TypeError[ERR_INVALID_ARG_TYPE]
are inconsistent. This change is to unify them.
PR-URL: https://github.com/nodejs/node/pull/16401
Fixes: https://github.com/nodejs/node/issues/16383
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test')
33 files changed, 46 insertions, 46 deletions
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 43473e3057..ad465d76ae 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -689,8 +689,8 @@ try { common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "block" argument must be of type function. Received ' + - `type ${typeName(block)}` + message: 'The "block" argument must be of type Function. Received ' + + 'type ' + typeName(block) })(e); } @@ -732,7 +732,7 @@ assert.throws(() => { { // bad args to AssertionError constructor should throw TypeError const args = [1, true, false, '', null, Infinity, Symbol('test'), undefined]; - const re = /^The "options" argument must be of type object$/; + const re = /^The "options" argument must be of type Object$/; args.forEach((input) => { assert.throws( () => new assert.AssertionError(input), diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 26923df004..15a6b9ebc6 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -934,8 +934,8 @@ assert.throws(() => Buffer.allocUnsafe(10).copy(), /TypeError: argument should be a Buffer/); const regErrorMsg = - new RegExp('The first argument must be one of type string, buffer, ' + - 'arrayBuffer, array, or array-like object\\.'); + new RegExp('The first argument must be one of type string, Buffer, ' + + 'ArrayBuffer, Array, or Array-like Object\\.'); assert.throws(() => Buffer.from(), regErrorMsg); assert.throws(() => Buffer.from(null), regErrorMsg); diff --git a/test/parallel/test-buffer-bytelength.js b/test/parallel/test-buffer-bytelength.js index 3d4ca1d184..45bd4cf3df 100644 --- a/test/parallel/test-buffer-bytelength.js +++ b/test/parallel/test-buffer-bytelength.js @@ -17,7 +17,7 @@ const vm = require('vm'); code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "string" argument must be one of type string, ' + - `buffer, or arrayBuffer. Received type ${typeof args[0]}` + `Buffer, or ArrayBuffer. Received type ${typeof args[0]}` } ); }); diff --git a/test/parallel/test-buffer-compare-offset.js b/test/parallel/test-buffer-compare-offset.js index 8458ae08fe..75cd9bed3d 100644 --- a/test/parallel/test-buffer-compare-offset.js +++ b/test/parallel/test-buffer-compare-offset.js @@ -70,5 +70,5 @@ assert.throws(() => a.compare(), common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "target" argument must be one of ' + - 'type buffer or uint8Array. Received type undefined' + 'type Buffer or Uint8Array. Received type undefined' })); diff --git a/test/parallel/test-buffer-compare.js b/test/parallel/test-buffer-compare.js index e764f49460..d404b36c64 100644 --- a/test/parallel/test-buffer-compare.js +++ b/test/parallel/test-buffer-compare.js @@ -32,7 +32,7 @@ const errMsg = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "buf1", "buf2" arguments must be one of ' + - 'type buffer or uint8Array' + 'type Buffer or Uint8Array' }, 2); assert.throws(() => Buffer.compare(Buffer.alloc(1), 'abc'), errMsg); @@ -42,5 +42,5 @@ assert.throws(() => Buffer.alloc(1).compare('abc'), common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "target" argument must be one of ' + - 'type buffer or uint8Array. Received type string' + 'type Buffer or Uint8Array. Received type string' })); diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js index 87ccb720b7..166d2eebb9 100644 --- a/test/parallel/test-buffer-concat.js +++ b/test/parallel/test-buffer-concat.js @@ -58,7 +58,7 @@ function assertWrongList(value) { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "list" argument must be one of type ' + - 'array, buffer, or uint8Array' + 'Array, Buffer, or Uint8Array' })); } diff --git a/test/parallel/test-buffer-equals.js b/test/parallel/test-buffer-equals.js index 9296b3f063..91c79a5be8 100644 --- a/test/parallel/test-buffer-equals.js +++ b/test/parallel/test-buffer-equals.js @@ -20,6 +20,6 @@ common.expectsError( code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "otherBuffer" argument must be one of type ' + - 'buffer or uint8Array. Received type string' + 'Buffer or Uint8Array. Received type string' } ); diff --git a/test/parallel/test-buffer-from.js b/test/parallel/test-buffer-from.js index c4d5e606dd..7e1bac3824 100644 --- a/test/parallel/test-buffer-from.js +++ b/test/parallel/test-buffer-from.js @@ -46,8 +46,8 @@ deepStrictEqual( const err = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The first argument must be one of type string, buffer, ' + - 'arrayBuffer, array, or array-like object. Received ' + + message: 'The first argument must be one of type string, Buffer, ' + + 'ArrayBuffer, Array, or Array-like Object. Received ' + `type ${actualType}` }); throws(() => Buffer.from(input), err); diff --git a/test/parallel/test-buffer-includes.js b/test/parallel/test-buffer-includes.js index 2d699315a6..609d931c87 100644 --- a/test/parallel/test-buffer-includes.js +++ b/test/parallel/test-buffer-includes.js @@ -282,7 +282,7 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "value" argument must be one of type string, ' + - `buffer, or uint8Array. Received type ${typeof val}` + `Buffer, or Uint8Array. Received type ${typeof val}` } ); }); diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js index 88de2b92d0..dbf84cd6ac 100644 --- a/test/parallel/test-buffer-indexof.js +++ b/test/parallel/test-buffer-indexof.js @@ -357,7 +357,7 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1); code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "value" argument must be one of type string, ' + - `buffer, or uint8Array. Received type ${typeof val}` + `Buffer, or Uint8Array. Received type ${typeof val}` } ); }); diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js index 92a148c0ba..33bcdcb669 100644 --- a/test/parallel/test-child-process-constructor.js +++ b/test/parallel/test-child-process-constructor.js @@ -19,7 +19,7 @@ function typeName(value) { }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "options" argument must be of type object. ' + + message: 'The "options" argument must be of type Object. ' + `Received type ${typeName(options)}` }); }); diff --git a/test/parallel/test-dgram-custom-lookup.js b/test/parallel/test-dgram-custom-lookup.js index ec6cef9e25..a418116598 100644 --- a/test/parallel/test-dgram-custom-lookup.js +++ b/test/parallel/test-dgram-custom-lookup.js @@ -41,7 +41,7 @@ const dns = require('dns'); }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "lookup" argument must be of type function' + message: 'The "lookup" argument must be of type Function' })); }); } diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js index 52c0a7d295..18ba8cddc7 100644 --- a/test/parallel/test-dns-lookup.js +++ b/test/parallel/test-dns-lookup.js @@ -12,7 +12,7 @@ assert.throws(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: /^The "hostname" argument must be one of type string or falsey/ + message: /^The "hostname" argument must be one of type string or falsy/ })); assert.throws(() => { diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 02bb5f7176..08a26ab218 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -123,7 +123,7 @@ assert.throws(() => { const errorReg = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: /^The "hostname" argument must be one of type string or falsey/ + message: /^The "hostname" argument must be one of type string or falsy/ }, 5); assert.throws(() => dns.lookup({}, common.mustNotCall()), errorReg); diff --git a/test/parallel/test-event-emitter-add-listeners.js b/test/parallel/test-event-emitter-add-listeners.js index 2a02a94940..448db80516 100644 --- a/test/parallel/test-event-emitter-add-listeners.js +++ b/test/parallel/test-event-emitter-add-listeners.js @@ -92,5 +92,5 @@ common.expectsError(() => { }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "listener" argument must be of type function' + message: 'The "listener" argument must be of type Function' }); diff --git a/test/parallel/test-event-emitter-once.js b/test/parallel/test-event-emitter-once.js index 35ebf72968..fa99a1362a 100644 --- a/test/parallel/test-event-emitter-once.js +++ b/test/parallel/test-event-emitter-once.js @@ -57,7 +57,7 @@ common.expectsError(() => { }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "listener" argument must be of type function' + message: 'The "listener" argument must be of type Function' }); { diff --git a/test/parallel/test-event-emitter-prepend.js b/test/parallel/test-event-emitter-prepend.js index 761eb6d904..dd9a9bdfc5 100644 --- a/test/parallel/test-event-emitter-prepend.js +++ b/test/parallel/test-event-emitter-prepend.js @@ -26,7 +26,7 @@ common.expectsError(() => { }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "listener" argument must be of type function' + message: 'The "listener" argument must be of type Function' }); // Test fallback if prependListener is undefined. diff --git a/test/parallel/test-event-emitter-remove-listeners.js b/test/parallel/test-event-emitter-remove-listeners.js index d4fb542270..612c405442 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/test/parallel/test-event-emitter-remove-listeners.js @@ -151,7 +151,7 @@ common.expectsError(() => { }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "listener" argument must be of type function' + message: 'The "listener" argument must be of type Function' }); { diff --git a/test/parallel/test-fs-copyfile.js b/test/parallel/test-fs-copyfile.js index 6220912b80..2977a59847 100644 --- a/test/parallel/test-fs-copyfile.js +++ b/test/parallel/test-fs-copyfile.js @@ -66,7 +66,7 @@ common.expectsError(() => { }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "callback" argument must be of type function' + message: 'The "callback" argument must be of type Function' }); // Throws if the source path is not a string. diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js index 23439baa32..50d80fd32a 100644 --- a/test/parallel/test-http-client-reject-unexpected-agent.js +++ b/test/parallel/test-http-client-reject-unexpected-agent.js @@ -53,7 +53,7 @@ server.listen(0, baseOptions.host, common.mustCall(function() { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: 'The "Agent option" argument must be one of type ' + - 'Agent-like object, undefined, or false' + 'Agent-like Object, undefined, or false' }) ); }); diff --git a/test/parallel/test-http-outgoing-proto.js b/test/parallel/test-http-outgoing-proto.js index c0ef90cdd9..47dbb07e2b 100644 --- a/test/parallel/test-http-outgoing-proto.js +++ b/test/parallel/test-http-outgoing-proto.js @@ -84,7 +84,7 @@ assert.throws(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The first argument must be one of type string or buffer' + message: 'The first argument must be one of type string or Buffer' })); assert.throws(() => { @@ -93,7 +93,7 @@ assert.throws(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The first argument must be one of type string or buffer' + message: 'The first argument must be one of type string or Buffer' })); // addTrailers() diff --git a/test/parallel/test-http2-createsecureserver-nooptions.js b/test/parallel/test-http2-createsecureserver-nooptions.js index 05029cba2b..8ff7f22e3f 100644 --- a/test/parallel/test-http2-createsecureserver-nooptions.js +++ b/test/parallel/test-http2-createsecureserver-nooptions.js @@ -10,7 +10,7 @@ const invalidOptions = [() => {}, 1, 'test', null, undefined]; const invalidArgTypeError = { type: TypeError, code: 'ERR_INVALID_ARG_TYPE', - message: 'The "options" argument must be of type object' + message: 'The "options" argument must be of type Object' }; // Error if options are not passed to createSecureServer diff --git a/test/parallel/test-http2-misc-util.js b/test/parallel/test-http2-misc-util.js index eaa297309b..993424f771 100644 --- a/test/parallel/test-http2-misc-util.js +++ b/test/parallel/test-http2-misc-util.js @@ -35,7 +35,7 @@ common.expectsError( { code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "test" argument must be of type object' + message: 'The "test" argument must be of type Object' }); common.expectsError( diff --git a/test/parallel/test-http2-util-asserts.js b/test/parallel/test-http2-util-asserts.js index 3e1703d158..ca25396a2c 100644 --- a/test/parallel/test-http2-util-asserts.js +++ b/test/parallel/test-http2-util-asserts.js @@ -15,7 +15,7 @@ const { new Date(), new (class Foo {})() ].forEach((i) => { - assert.doesNotThrow(() => assertIsObject(i, 'foo', 'object')); + assert.doesNotThrow(() => assertIsObject(i, 'foo', 'Object')); }); [ @@ -27,10 +27,10 @@ const { [], [{}] ].forEach((i) => { - assert.throws(() => assertIsObject(i, 'foo', 'object'), + assert.throws(() => assertIsObject(i, 'foo', 'Object'), common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', - message: /^The "foo" argument must be of type object$/ + message: /^The "foo" argument must be of type Object$/ })); }); diff --git a/test/parallel/test-process-cpuUsage.js b/test/parallel/test-process-cpuUsage.js index a6e799ca1b..92c7b74c59 100644 --- a/test/parallel/test-process-cpuUsage.js +++ b/test/parallel/test-process-cpuUsage.js @@ -34,13 +34,13 @@ for (let i = 0; i < 10; i++) { const invalidUserArgument = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "preValue.user" property must be of type Number' + message: 'The "preValue.user" property must be of type number' }, 8); const invalidSystemArgument = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "preValue.system" property must be of type Number' + message: 'The "preValue.system" property must be of type number' }, 2); diff --git a/test/parallel/test-process-kill-pid.js b/test/parallel/test-process-kill-pid.js index 994a19f5cc..b020f6bc61 100644 --- a/test/parallel/test-process-kill-pid.js +++ b/test/parallel/test-process-kill-pid.js @@ -41,7 +41,7 @@ const assert = require('assert'); const invalidPidArgument = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "pid" argument must be of type Number' + message: 'The "pid" argument must be of type number' }, 6); assert.throws(function() { process.kill('SIGTERM'); }, diff --git a/test/parallel/test-tls-no-cert-required.js b/test/parallel/test-tls-no-cert-required.js index b850a56eb3..e5461d2291 100644 --- a/test/parallel/test-tls-no-cert-required.js +++ b/test/parallel/test-tls-no-cert-required.js @@ -43,7 +43,7 @@ assert.throws(() => tls.createServer('this is not valid'), common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "options" argument must be of type object' + message: 'The "options" argument must be of type Object' }) ); diff --git a/test/parallel/test-url-format-invalid-input.js b/test/parallel/test-url-format-invalid-input.js index cc4f6bdc0f..a94546aaf2 100644 --- a/test/parallel/test-url-format-invalid-input.js +++ b/test/parallel/test-url-format-invalid-input.js @@ -17,7 +17,7 @@ for (const [urlObject, type] of throwsObjsAndReportTypes) { const error = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "urlObject" argument must be one of type object or string. ' + + message: 'The "urlObject" argument must be one of type Object or string. ' + `Received type ${type}` }); assert.throws(function() { url.format(urlObject); }, error); diff --git a/test/parallel/test-url-format-whatwg.js b/test/parallel/test-url-format-whatwg.js index 9174c5a274..c26000cb56 100644 --- a/test/parallel/test-url-format-whatwg.js +++ b/test/parallel/test-url-format-whatwg.js @@ -24,7 +24,7 @@ assert.strictEqual( const expectedErr = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "options" argument must be of type object' + message: 'The "options" argument must be of type Object' }, 4); assert.throws(() => url.format(myURL, true), expectedErr); assert.throws(() => url.format(myURL, 1), expectedErr); diff --git a/test/parallel/test-util-callbackify.js b/test/parallel/test-util-callbackify.js index 1eb940bf13..0999fc4fd3 100644 --- a/test/parallel/test-util-callbackify.js +++ b/test/parallel/test-util-callbackify.js @@ -234,7 +234,7 @@ const values = [ }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "original" argument must be of type function' + message: 'The "original" argument must be of type Function' })); }); } @@ -255,7 +255,7 @@ const values = [ }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The last argument must be of type function' + message: 'The last argument must be of type Function' })); }); } diff --git a/test/parallel/test-util-inherits.js b/test/parallel/test-util-inherits.js index 342e1f03f7..f05135ec78 100644 --- a/test/parallel/test-util-inherits.js +++ b/test/parallel/test-util-inherits.js @@ -6,7 +6,7 @@ const inherits = require('util').inherits; const errCheck = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "superCtor" argument must be of type function' + message: 'The "superCtor" argument must be of type Function' }); // super constructor @@ -85,7 +85,7 @@ assert.throws(function() { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "superCtor.prototype" property must be of type function' + message: 'The "superCtor.prototype" property must be of type Function' }) ); assert.throws(function() { @@ -96,6 +96,6 @@ assert.throws(function() { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "ctor" argument must be of type function' + message: 'The "ctor" argument must be of type Function' }) ); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index ecdaf0f1a4..c0f0c6b644 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1136,7 +1136,7 @@ if (typeof Symbol !== 'undefined') { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "options" argument must be of type object' + message: 'The "options" argument must be of type Object' }) ); @@ -1145,7 +1145,7 @@ if (typeof Symbol !== 'undefined') { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: 'The "options" argument must be of type object' + message: 'The "options" argument must be of type Object' }) ); } diff --git a/test/sequential/test-inspector-module.js b/test/sequential/test-inspector-module.js index c0dc71efbf..af0154f7ce 100644 --- a/test/sequential/test-inspector-module.js +++ b/test/sequential/test-inspector-module.js @@ -43,7 +43,7 @@ assert.doesNotThrow( code: 'ERR_INVALID_ARG_TYPE', type: TypeError, message: - 'The "params" argument must be of type object. ' + + 'The "params" argument must be of type Object. ' + `Received type ${typeof i}` } ); |