diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-10-03 02:38:37 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-10-10 21:36:20 -0700 |
commit | 2664dacf7e0e13dc24485836e66081fb07ee1289 (patch) | |
tree | 38443f5af4bee045c4d9861f84c1e0c2f08c763c /test | |
parent | 3aeae8d81b7b78668c37f7a07a72d94781126d49 (diff) | |
download | android-node-v8-2664dacf7e0e13dc24485836e66081fb07ee1289.tar.gz android-node-v8-2664dacf7e0e13dc24485836e66081fb07ee1289.tar.bz2 android-node-v8-2664dacf7e0e13dc24485836e66081fb07ee1289.zip |
util: validate formatWithOptions inspectOptions
This makes sure that the `inspectOptions` are validated. This could
otherwise cause confusion.
Fixes: https://github.com/nodejs/node/issues/29726
PR-URL: https://github.com/nodejs/node/pull/29824
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-util-format.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index 810e9ac114..2ef0528490 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -408,3 +408,20 @@ assert.strictEqual( ), '[ 1, [Object] ]' ); + +[ + undefined, + null, + false, + 5n, + 5, + 'test', + Symbol() +].forEach((invalidOptions) => { + assert.throws(() => { + util.formatWithOptions(invalidOptions, { a: true }); + }, { + code: 'ERR_INVALID_ARG_TYPE', + message: /"inspectOptions".+object/ + }); +}); |