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

Compare for equality, not approximate equality within a tolerance of 0.0. #7291

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

copybara-service[bot]
Copy link
Contributor

Compare for equality, not approximate equality within a tolerance of 0.0.

IIRC, the behavior of the two differs only for:

  • comparing NaN to itself
  • comparing either infinity to itself
  • comparing positive zero to negative zero

And as best I can tell, the only one of those that has any chance of coming up in these tests is the zero case. And, as best I can tell, in those cases, we actively want to test that we're returning positive zero, not negative zero. So let's test for that, and let's simplify the code in doing so.

(followup to cl/649135877; "followup" to cl/108355695, which ported these assertions from JUnit, known for steering users away from exact-equality comparisons)

RELNOTES=n/a

…`0.0`.

IIRC, the behavior of the two differs only for:
- comparing NaN to itself
- comparing either infinity to itself
- comparing positive zero to negative zero

And as best I can tell, the only one of those that has any chance of coming up in these tests is the zero case. And, as best I can tell, in those cases, we actively want to test that we're returning positive zero, not negative zero. So let's test for that, and let's simplify the code in doing so.

(followup to cl/649135877; "followup" to cl/108355695, which ported these assertions from JUnit, known for steering users away from exact-equality comparisons)

RELNOTES=n/a
PiperOrigin-RevId: 649195688
@copybara-service copybara-service bot merged commit 8dac907 into master Jul 3, 2024
@copybara-service copybara-service bot deleted the test_649167803 branch July 3, 2024 21:17
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.

1 participant