diff --git a/lib/util.js b/lib/util.js index d4b87eaeb0a58f..bb588cf475e236 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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'); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 68f8a228b81ac3..14b7929ae5af4c 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -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]');