-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: add prototype support for boxed primitives #27351
Closed
BridgeAR
wants to merge
1
commit into
nodejs:master
from
BridgeAR:add-prototype-support-boxed-primitive
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👆 😮 |
||
); | ||
assert.strictEqual(util.inspect(new Number(-1.1)), '[Number: -1.1]'); | ||
assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]'); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Not a blocking comment.. But my thoughts..For objects, null prototype is showed as
[Object: null prototype] {}
, looks like for primitives, we show as[Boolean (null prototype): true]
(like in test), may be we can show like[Boolean: null prototype] true
, so that reading is consistent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that as well but I think it would be less obvious that it's a boxed primitive in that case (obviously, e.g.,
5
is a number, so it might also just stand for extra information?).The inconsistency is not ideal but this is likely going to be a super rare case anyway.