-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Fix rounding algorithm #958
Conversation
Pull Request Test Coverage Report for Build 2450189177
💛 - Coveralls |
@adriancable would you mind reviewing this PR? |
The failure is originated from the new rounding algorithm. Im gonna fix this after WWDC 🥳 |
It’s not sufficient to check that stepValue != null. It could also be undefined or 0. Either will lead to an overflow which is what happens in your test. |
We should not handle stepValue which is undefined or 0. And the test failure is not a kind of overflow. |
I think this looks OK now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. There were some other edge cases discussed in the issue form right? Would it make sense to add them to the suite of test cases to avoid any future regressions?
Possibly one edge case. Basically all characteristics have Although this can be happened, it is more like the developer sets non-null properties as null which cannot be detected in compile-time. |
♻️ Current situation
Related:
💡 Proposed solution
As @adriancable have mentioned in #956, the previous solution may have possible incorrect behaviors.
So I have tried all possible tests which can be happened in 0 and 100.
I moved the rounding logic in front of clamping logic.
Plus, to fix in case the error is smaller than epsilon and greater than 0.5, I have changed
Math.round()
toMath.floor()
.We don't need round the value in server-side, due to Apple Home app will always automatically round the value fit to step size.
⚙️ Release Notes
➕ Additional Information
Testing
I have rewritten entire test code related with this issue.
The
minStep
in the final test only uses (100/6), of course I have tried other combinations like 3, 7, 9.All cases have passed, including approaches which @adriancable have mentioned before.
The test takes up to 3 minutes per step, this is the reason why I have decided to use only 100/6.
Reviewer Nudging
I would appreciate if you have better idea.