Skip to content
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

Add Values method to PathStep #119

Merged
merged 1 commit into from
Feb 26, 2019
Merged

Add Values method to PathStep #119

merged 1 commit into from
Feb 26, 2019

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Feb 26, 2019

Some of the value information is already in the path (e.g., MapIndex.Key
and SliceIndex.Key), which seems to suggest that all of the value information
should be in the Path. Doing so has several benefits:
* It simplifies the comparison logic
* It paves the way for FilterPath to be able to ignore missing
slice elements or map entries
* It allows for a simpler API for custom reporters

One regression introduced by this change is the removal of batching for
slices when sufficient number of elements differ. This logic was added
as a hack in the past to keep the reporter output small in such cases.
However, this batching functionality should be the responsibility of the
reporter logic, not the comparer logic. A future change will refactor
the reporter logic to reintroduce that feature.

@dsnet dsnet requested a review from neild February 26, 2019 02:12
@dsnet dsnet force-pushed the step-values branch 2 times, most recently from 222f53c to 3f732b3 Compare February 26, 2019 02:31
Copy link

@cybrcodr cybrcodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not as familiar, but delta makes sense to me. Just a couple of questions.

cmp/compare.go Outdated Show resolved Hide resolved
@@ -411,14 +415,15 @@ const (
func reporter(r interface {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious. Why is this not just reporterIface?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Reporter is exported, it avoids the need to also export another type with a name. It's kind of minor, but you may have noticed that I have an aversion towards naming things ;)

Some of the value information is already in the path (e.g., MapIndex.Key
and SliceIndex.Key), which seems to suggest that all of the value information
should be in the Path. Doing so has several benefits:
	* It simplifies the comparison logic
	* It paves the way for FilterPath to be able to ignore missing
	slice elements or map entries
	* It allows for a simpler API for custom reporters

One regression introduced by this change is the removal of batching for
slices when sufficient number of elements differ. This logic was added
as a hack in the past to keep the reporter output small in such cases.
However, this batching functionality should be the responsibility of the
reporter logic, not the comparer logic. A future change will refactor
the reporter logic to reintroduce that feature.
@dsnet dsnet merged commit 7586b66 into master Feb 26, 2019
@dsnet dsnet deleted the step-values branch February 26, 2019 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants