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

expect_equals sometimes reports incorrect values when values are not equal #1955

Closed
JimMcL opened this issue May 7, 2024 · 2 comments · Fixed by #2009
Closed

expect_equals sometimes reports incorrect values when values are not equal #1955

JimMcL opened this issue May 7, 2024 · 2 comments · Fixed by #2009
Labels
bug an unexpected problem or unintended behavior expectation 🙀
Milestone

Comments

@JimMcL
Copy link

JimMcL commented May 7, 2024

The values reported by expect_equal for actual and expected in the case of a test failure are occasionally rounded in incorrect/inconsistent ways. It appears to be an edge case activated by 0.5 values.
Example:

> expect_equal(c(8.5, 9.5), c(1.5, 2.5))
Error: c(8.5, 9.5) (`actual`) not equal to c(1.5, 2.5) (`expected`).

  `actual`: 8 10
`expected`: 2  2

Note the reported values for actual and expected.

@HHayman
Copy link

HHayman commented Jun 7, 2024

Unless there is a desire to keep the formatting as it is, I would be happy to try and address this by refactoring the sprintf formatting?

@hadley
Copy link
Member

hadley commented Oct 22, 2024

This is fixed in the dev version of waldo (which I plan to release to CRAN soon). Now you'll see:

  `actual`: 8.5 9.5
`expected`: 1.5 2.5

I'll leave this issue open as a reminder to myself to bump the required waldo version in testthat.

@hadley hadley added feature a feature request or enhancement expectation 🙀 labels Oct 22, 2024
@hadley hadley added this to the v3.2.2 milestone Oct 22, 2024
@hadley hadley added bug an unexpected problem or unintended behavior and removed feature a feature request or enhancement labels Oct 22, 2024
hadley added a commit that referenced this issue Nov 4, 2024
@hadley hadley closed this as completed in f5ba8a8 Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior expectation 🙀
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants