mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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:
2 files changed
+56
-28
No files matched your search
@@ -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]');
|
||||
|
||||
|
||||
Reference in new issue
Block a user