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

Improve failure output when comparing different pointers #136

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

frankban
Copy link
Owner

Fixes #133

Copy link
Contributor

@rogpeppe rogpeppe 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 sure that this is quite right for the reason I've outlined. WDYT?

checker.go Outdated
@@ -100,6 +100,18 @@ func (c *equalsChecker) Check(got interface{}, args []interface{}, note func(key
}
}
}

if reflect.ValueOf(got).Kind() == reflect.Ptr && reflect.ValueOf(want).Kind() == reflect.Ptr && Format(got) == Format(want) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this isn't quite right when a custom formatter is used. I'm not sure what the right solution is there though.

Perhaps the answer is to move the logic into the printer, so it never prints as "same as" when the pointer values are the same, but instead prints something like <same content as "foo" but with different pointer value> or something?

WDYT?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good idea, done.

@frankban frankban force-pushed the different-pointers-same-format branch from 69b013a to b54892e Compare March 22, 2022 20:51
@frankban frankban force-pushed the different-pointers-same-format branch from b54892e to ed9fd1f Compare March 22, 2022 20:53
@frankban frankban merged commit 5315a53 into master Mar 24, 2022
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.

confusing failure when using qt.Equals with pointers
2 participants