diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-08-13 00:22:52 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-08-19 19:00:31 +0200 |
commit | bd090f9220c3a36891f348f50578ff961deadba1 (patch) | |
tree | acf7fe1683e1e73dd5e827a31efc7adf81d0a40a /test/parallel/test-util-inspect.js | |
parent | a04f2f7df630427bf869b1e04040975b752973b6 (diff) | |
download | android-node-v8-bd090f9220c3a36891f348f50578ff961deadba1.tar.gz android-node-v8-bd090f9220c3a36891f348f50578ff961deadba1.tar.bz2 android-node-v8-bd090f9220c3a36891f348f50578ff961deadba1.zip |
util: mark special entries as such
This adds the color code to special entries if colors are active.
PR-URL: https://github.com/nodejs/node/pull/22287
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-util-inspect.js')
-rw-r--r-- | test/parallel/test-util-inspect.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 6501187528..433b16c39e 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1647,3 +1647,30 @@ assert.strictEqual(inspect(new BigUint64Array([0n])), 'BigUint64Array [ 0n ]'); '{ [Non\\nenumerable\\tkey]: true }' ); } + +// Check for special colors. +{ + const special = inspect.colors[inspect.styles.special]; + const string = inspect.colors[inspect.styles.string]; + + assert.strictEqual( + inspect(new WeakSet(), { colors: true }), + `WeakSet { \u001b[${special[0]}m<items unknown>\u001b[${special[1]}m }` + ); + assert.strictEqual( + inspect(new WeakMap(), { colors: true }), + `WeakMap { \u001b[${special[0]}m<items unknown>\u001b[${special[1]}m }` + ); + assert.strictEqual( + inspect(new Promise(() => {}), { colors: true }), + `Promise { \u001b[${special[0]}m<pending>\u001b[${special[1]}m }` + ); + + const rejection = Promise.reject('Oh no!'); + assert.strictEqual( + inspect(rejection, { colors: true }), + `Promise { \u001b[${special[0]}m<rejected>\u001b[${special[1]}m ` + + `\u001b[${string[0]}m'Oh no!'\u001b[${string[1]}m }` + ); + rejection.catch(() => {}); +} |