diff --git a/lib/util.js b/lib/util.js index cd643c3120714a..8d9afe921f4292 100644 --- a/lib/util.js +++ b/lib/util.js @@ -314,6 +314,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 e0264c34f7b685..98567027dd3519 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -333,6 +333,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]');