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
Float comparisons failing on unit tests with sebastian/comparator >= 4.0.8 #36167
Comments
Hi @francisco-serfe. Thank you for your report.
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-November. Thank you for working on this issue.
|
Hi @francisco-serfe , |
@engcom-November, what do you mean it doesn't come with a Magento installation? Yes it does, see here... @francisco-serfe: does it still trigger even if you update phpunit to the latest compatible version? |
I didn't pursue the issue since they'd eventually run into it anyways when they updated PHPUnit
I just ended up fixing our |
Well, reason I'm asking is because I think this was fixed in phpunit 9.5.25, when you can confirm, we don't need to reopen this issue 🙂 |
Hmm, nope, no dice.
|
Okay, thanks for confirming! @engcom-November, @sdzhepa: I believe this issue needs to be reopened... |
Also should mention I've experienced this on CE |
Hello, We are reopening this issue to process it further. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-7097 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-November. Thank you for verifying the issue. |
I don't know Magento or what your test are actually doing, but I ran into this same issue after upgrading the library in my own Laravel repo, and then found this thread as the top search result. Here's what I found, in case it helps anyone else. Old tests were passing but weren't actually correct before 4.0.8. You can see the behavior by writing this test: public function testFloat()
{
// Passes with 4.0.6, fails with 4.0.8.
$this->assertEquals(0.21399575471878052, 0.21399575471878002);
} Previously it was dropping off the last 3 values of precision, ending at Our database column is defined as Really, none of us should be comparing floats directly anyway (that's why bcmath and |
Do we have any workable for now? |
It looks like some commits got added to 2.4-develop branch yesterday that will probably fix this, see: https://github.com/search?q=repo%3Amagento%2Fmagento2+float+comparison+precision&type=commits So I think this ticket can be closed? Maybe somebody first wants to confirm? |
Preconditions and environment
Steps to reproduce
Run the MFTF unit tests over Sales, SalesRule and Tax modules.
Expected result
Tests pass.
Actual result
Additional information
See:
PHP_FLOAT_EPSILON
sebastianbergmann/phpunit#4972I'm guessing what should be done here is using assertEqualsWithDelta() instead.
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: