Skip to content

Commit

Permalink
util: inspect boxed symbols like other primitives
Browse files Browse the repository at this point in the history
Inspect boxed symbol objects in the same way other boxed primitives
are inspected.

Fixes: #7639
PR-URL: #7641
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
addaleax committed Jul 17, 2016
1 parent d4debb9 commit 35e8c94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ function formatValue(ctx, value, recurseTimes) {
formatted = formatPrimitiveNoColor(ctx, raw);
return ctx.stylize('[String: ' + formatted + ']', 'string');
}
if (typeof raw === 'symbol') {
formatted = formatPrimitiveNoColor(ctx, raw);
return ctx.stylize('[Symbol: ' + formatted + ']', 'symbol');
}
if (typeof raw === 'number') {
formatted = formatPrimitiveNoColor(ctx, raw);
return ctx.stylize('[Number: ' + formatted + ']', 'number');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ test_lines({

// test boxed primitives output the correct values
assert.equal(util.inspect(new String('test')), '[String: \'test\']');
assert.equal(util.inspect(Object(Symbol('test'))), '[Symbol: Symbol(test)]');
assert.equal(util.inspect(new Boolean(false)), '[Boolean: false]');
assert.equal(util.inspect(new Boolean(true)), '[Boolean: true]');
assert.equal(util.inspect(new Number(0)), '[Number: 0]');
Expand Down

0 comments on commit 35e8c94

Please sign in to comment.