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

refactor and improvements #49

Closed
wants to merge 1 commit into from
Closed

Conversation

puellanivis
Copy link

@puellanivis puellanivis commented Aug 20, 2021

Addresses:

Additional edge-cases #48

  • Stronger checks on Equal(bType) (…) to ensure it returns a bool kind, before executing it and panicking on it being non-Bool
  • Consider negative zero as equal to zero. (IEEE 754 defines that negative zero and positive zero should normally compare equal)
  • Part of checking pointers and interfaces before using Elem(), we check to see if they are nil first, and allows more clarity between getting a zero reflect.Value vs having a typed-pointer that is nil. (This means differences are reported as <nil pointer != *bType rather than <nil pointer> != bType.)
  • Comparing an untyped nil, (for instance a nil value assigned into an interface) the difference will be reported as <untyped nil> != b
  • signigifcantly overhauled all of the tests to focus on some functions shouldBeEqual vs shouldBeDiffs, and using deterministic values for time.Time comparisons rather than time.Now() so we can test the actual output of the tests, rather than focusing only on “differences were found”.

@daniel-nichter
Copy link
Member

Hello 👋 Thanks for the PR and fixes. I'd like to include this work, but the blocker is the changes to the test suite. Given the complexity of this pkg, the test suite is critical to ensure that no regressions are introduced. Since the test suite was essentially rewritten top to bottom, I can't tell if the original test suite still passed with the code changes and additions. The new test suite passes, but without a painstaking review of the 1,300+ lines changed, we can't know with certainty if that's coincidence or not.

So to merge this, please revert the test suite and only append new tests for the new functionality. Please also keep the existing code style, i.e. tests are in-place, not factored out to functions like shouldBeEqual which make line numbers reported by t.Error() meaningless.

Overall, these changes might be better as separate PRs. The 400+ line changes to the main code are difficult to compare. It'd be a lot easier to take it one by one because, again, the code is complex and tiny details matter. After all, this code is 4 years of fine tweaks and edits by 10 other engineers, so I'm trying to preserve their work and fixes, too.

@puellanivis
Copy link
Author

I had already considered the line number issue, which is why the helper functions call t.Helper(), so that they are skipped when printing file:lineno in the test results.

I’ll consider breaking things out into separate PRs 🤔 and limiting the test changes to an absolute minimum for each.

@gaby
Copy link

gaby commented Oct 1, 2022

@puellanivis @daniel-nichter Any updates on this?

@puellanivis
Copy link
Author

My company pivoted away from Go, so I haven’t had the time on their behalf to work on breaking things up properly.

@daniel-nichter
Copy link
Member

My company pivoted away from Go

Sorry to hear that. Perhaps I'll try to implement/fix some items from your list in issue #48.

For now, I'll close this PR but keep that issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants