Repository navigation
Demo: simplify money() with round() — CI catches a half-cent bug - #6
Draft
NailKarimov wants to merge 1 commit into
Draft
NailKarimov wants to merge 1 commit into
NailKarimov wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SwMkm9aNCkt1zWgTtAG3xw
Test results❌ Do not merge
Full log and Hypothesis output: run 40409112932. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
This is a demo pull request. It stays open on purpose and is never merged.
It shows how the suite and CI react to a realistic change that looks harmless in review.
The change
money()rounds every amount to cents. This PR "simplifies" it:It reads as a clean refactor, the linters and mypy pass, and the diff is three lines. But Python's
round()on aDecimaluses banker's rounding (half to even), while a till rounds half up. Every amount that ends inexactly half a cent now rounds the other way.
What the tests say
independent implementation of the price rules. It shrinks the failure to the smallest case:
two items at 0.01 with the SAVE25 coupon. 25 % of 0.02 is 0.005: the oracle gives a 0.01 discount, the service now
gives 0.00, and the customer pays 5.01 instead of 5.00.
Where to look
testjob is red; its summary has the verdict and the failing test, and the annotationpoints at the line of the test that caught it, with the shrunk example.
Planted bug M1 in
scripts/mutants.pyis the same mistake; the mutation checkshows that only the property-based test catches it.
Decision
Do not merge. Keep
quantize(CENT, rounding=ROUND_HALF_UP).Generated by Claude Code