Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
util: add coverage for util.inspect.colors alias setter
Add test to confirm that the setter for aliases in `util.inspect.colors`
keeps the alias reference-equal to the target value.

Refs: https://coverage.nodejs.org/coverage-5b0308cd823a5110/lib/internal/util/inspect.js.html#L357
Refs: https://codecov.io/gh/nodejs/node/src/5b0308cd823a511098dadf9ddd5a35e3a9dbb424/lib/internal/util/inspect.js#L357
  • Loading branch information
Trott committed Feb 11, 2020
commit 0039732046e1a37e0daa435846deb3642265955c
18 changes: 18 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2723,3 +2723,21 @@ assert.strictEqual(
'\x1B[2mdef: \x1B[33m5\x1B[39m\x1B[22m }'
);
}

// Test changing util.inspect.colors colors and aliases. Since this might have
// side effects, we do it last.
{
Comment thread
Trott marked this conversation as resolved.
const colors = util.inspect.colors;
// "grey" is reference-equal alias of "gray".
assert.strictEqual(colors.grey, colors.gray);

// Assigninging one should assign the other. This tests that the alias setter
// function keeps things reference-equal.
colors.gray = [0, 0];
assert.deepStrictEqual(colors.gray, [0, 0]);
assert.strictEqual(colors.grey, colors.gray);

colors.grey = [1, 1];
assert.deepStrictEqual(colors.grey, [1, 1]);
assert.strictEqual(colors.grey, colors.gray);
}