-
Notifications
You must be signed in to change notification settings - Fork 209
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
Fix uint to format in decimal #199
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
25349ef
Fix uint to format in decimal
178inaba 7cfa7da
Fix uint slice to format in decimal
178inaba 18910c2
Add comment to uint8 and uintptr format
178inaba c00592f
Fix to split switch case for uint8 and uintptr formats
178inaba 1a0ffc6
Fix uint8 to format in decimal
178inaba 1f7bef0
Fix to format in hex for uint8 slice
178inaba 4ee30ba
Fix to format in hex for uint8 slice
178inaba 8b1b10c
Fix test
178inaba db6f2d4
Fix condition to single line
178inaba 6458fc5
Fix variable name from `isSlice` to `withinSlice`
178inaba 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,14 +81,20 @@ func (opts formatOptions) FormatDiff(v *valueNode) textNode { | |
return opts.FormatDiffSlice(v) | ||
} | ||
|
||
var isSlice bool | ||
if v.parent != nil && | ||
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. (Stye-nit): Keep conditional as single line. |
||
(v.parent.Type.Kind() == reflect.Slice || v.parent.Type.Kind() == reflect.Array) { | ||
isSlice = true | ||
} | ||
|
||
// For leaf nodes, format the value based on the reflect.Values alone. | ||
if v.MaxDepth == 0 { | ||
switch opts.DiffMode { | ||
case diffUnknown, diffIdentical: | ||
// Format Equal. | ||
if v.NumDiff == 0 { | ||
outx := opts.FormatValue(v.ValueX, visitedPointers{}) | ||
outy := opts.FormatValue(v.ValueY, visitedPointers{}) | ||
outx := opts.FormatValue(v.ValueX, isSlice, visitedPointers{}) | ||
outy := opts.FormatValue(v.ValueY, isSlice, visitedPointers{}) | ||
if v.NumIgnored > 0 && v.NumSame == 0 { | ||
return textEllipsis | ||
} else if outx.Len() < outy.Len() { | ||
|
@@ -101,8 +107,8 @@ func (opts formatOptions) FormatDiff(v *valueNode) textNode { | |
// Format unequal. | ||
assert(opts.DiffMode == diffUnknown) | ||
var list textList | ||
outx := opts.WithTypeMode(elideType).FormatValue(v.ValueX, visitedPointers{}) | ||
outy := opts.WithTypeMode(elideType).FormatValue(v.ValueY, visitedPointers{}) | ||
outx := opts.WithTypeMode(elideType).FormatValue(v.ValueX, isSlice, visitedPointers{}) | ||
outy := opts.WithTypeMode(elideType).FormatValue(v.ValueY, isSlice, visitedPointers{}) | ||
if outx != nil { | ||
list = append(list, textRecord{Diff: '-', Value: outx}) | ||
} | ||
|
@@ -111,9 +117,9 @@ func (opts formatOptions) FormatDiff(v *valueNode) textNode { | |
} | ||
return opts.WithTypeMode(emitType).FormatType(v.Type, list) | ||
case diffRemoved: | ||
return opts.FormatValue(v.ValueX, visitedPointers{}) | ||
return opts.FormatValue(v.ValueX, isSlice, visitedPointers{}) | ||
case diffInserted: | ||
return opts.FormatValue(v.ValueY, visitedPointers{}) | ||
return opts.FormatValue(v.ValueY, isSlice, visitedPointers{}) | ||
default: | ||
panic("invalid diff mode") | ||
} | ||
|
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
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
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.
Perhaps call this
withinSlice
instead (here and elsewhere)? Since we're usually looking at this variable from the perspective of the child.