Skip to content

Commit 0858e62

Browse files
addaleaxevanlucas
authored andcommitted
util: inspect boxed symbols like other primitives
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]>
1 parent 939cf6d commit 0858e62

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

‎lib/util.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ function formatValue(ctx, value, recurseTimes){
413413
formatted=formatPrimitiveNoColor(ctx,raw);
414414
returnctx.stylize('[String: '+formatted+']','string');
415415
}
416+
if(typeofraw==='symbol'){
417+
formatted=formatPrimitiveNoColor(ctx,raw);
418+
returnctx.stylize('[Symbol: '+formatted+']','symbol');
419+
}
416420
if(typeofraw==='number'){
417421
formatted=formatPrimitiveNoColor(ctx,raw);
418422
returnctx.stylize('[Number: '+formatted+']','number');

‎test/parallel/test-util-inspect.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ test_lines({
474474

475475
// test boxed primitives output the correct values
476476
assert.equal(util.inspect(newString('test')),'[String: \'test\']');
477+
assert.equal(util.inspect(Object(Symbol('test'))),'[Symbol: Symbol(test)]');
477478
assert.equal(util.inspect(newBoolean(false)),'[Boolean: false]');
478479
assert.equal(util.inspect(newBoolean(true)),'[Boolean: true]');
479480
assert.equal(util.inspect(newNumber(0)),'[Number: 0]');

0 commit comments

Comments
(0)