util: inspect boxed symbols like other primitives
Inspect boxed symbol objects in the same way other boxed primitives are inspected. Fixes: https://github.com/nodejs/node/issues/7639 PR-URL: https://github.com/nodejs/node/pull/7641 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
d4debb990f
commit
35e8c9481f
@ -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');
|
||||
|
@ -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]');
|
||||
|
Loading…
x
Reference in New Issue
Block a user