fix: compute DiceRoll success count from fresh roll, not stale result (Closes #16) #39
Reference in New Issue
Block a user
Delete Branch "feature/issue-16-fix-diceroll-success-counting-bug"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
DiceRoll.roll():numberOfSuccesseswas computed from the stalethis.result(empty list) instead of the freshly rolled values, causing it to always be 0 on first rollcopy()evaluates all arguments usingthisstate before creating the new object, soresult.countSuccesses()referenced the old empty listnewResultand use it for bothresultandnumberOfSuccessesin thecopy()callTest plan
DiceTest.ktall passing (verified via./gradlew :sharedUI:jsTest)rollProducesCorrectSuccessCount-- verifies success count matches actual dice >= 5rollWithCustomThresholdProducesCorrectSuccessCount-- verifies with threshold 4rollResultHasCorrectNumberOfDice-- verifies result list sizecountSuccessesExtensionFunction-- direct test of the extension functionfreshRollDoesNotUseStaleResult-- specifically tests the bug scenario (empty initial result)consecutiveRollsProduceIndependentResults-- verifies multiple independent rollsCloses #16
Generated with Claude Code