util: add prototype support for boxed primitives

This makes sure manipulated prototypes from boxed primitives will
be highlighted. It also makes sure that a potential `Symbol.toStringTag`
is taken into account.

PR-URL: https://github.com/nodejs/node/pull/27351
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Ruben Bridgewater authored and Michaël Zasso committed 2019-04-27 11:36:08 +02:00
1 parent e7026f1428
commit ae2333db65
2 files changed
+56 -28

No files matched your search

+14 -2
View File
@@ -856,9 +856,21 @@ assert.strictEqual(
'[Symbol: Symbol(test)]'
);
assert.strictEqual(util.inspect(new Boolean(false)), '[Boolean: false]');
assert.strictEqual(util.inspect(new Boolean(true)), '[Boolean: true]');
assert.strictEqual(
util.inspect(Object.setPrototypeOf(new Boolean(true), null)),
'[Boolean (null prototype): true]'
);
assert.strictEqual(util.inspect(new Number(0)), '[Number: 0]');
assert.strictEqual(util.inspect(new Number(-0)), '[Number: -0]');
assert.strictEqual(
util.inspect(
Object.defineProperty(
Object.setPrototypeOf(new Number(-0), Array.prototype),
Symbol.toStringTag,
{ value: 'Foobar' }
)
),
'[Number (Array): -0] [Foobar]'
);
assert.strictEqual(util.inspect(new Number(-1.1)), '[Number: -1.1]');
assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');