Skip to content

Commit fa0b382

Browse files
IanWhitneyInsti
authored andcommitted
[Bowling] Add edge case with fill balls in a last-frame strike (#418)
* Add edge case with fill balls in a last-frame strike The previous test does not quite capture the behavior. If the first fill fill is a non-strikes, then the total fill-ball score must be less than 10. But, if the first fill ball is a strike, then the total fill-ball score must be less than 20. Because that first fill-ball strike resets the pins. I had what I thought was a working implementation but it totally missed the 2nd case. Adding a test to cover that case. * Add edge case test for final-strike fill balls This test checks that the fill balls validate correctly if the 2nd ball is a strike. #418 (comment) .
1 parent 229c941 commit fa0b382

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

exercises/bowling/canonical-data.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"score": {
1717
"description": [
18-
"Returns the final score of a bowling game"
18+
"returns the final score of a bowling game"
1919
],
2020
"cases": [{
2121
"description": "should be able to score a game with all zeros",
@@ -74,31 +74,39 @@
7474
"rolls": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
7575
"expected": 300
7676
}, {
77-
"description": "Rolls can not score negative points",
77+
"description": "rolls can not score negative points",
7878
"rolls": [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
7979
"expected": -1
8080
}, {
81-
"description": "A roll can not score more than 10 points",
81+
"description": "a roll can not score more than 10 points",
8282
"rolls": [11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
8383
"expected": -1
8484
}, {
85-
"description": "Two rolls in a frame can not score more than 10 points",
85+
"description": "two rolls in a frame can not score more than 10 points",
8686
"rolls": [5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
8787
"expected": -1
8888
}, {
89-
"description": "Two bonus rolls after a strike in the last frame can not score more than 10 points",
89+
"description": "two bonus rolls after a strike in the last frame can not score more than 10 points",
9090
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 6],
9191
"expected": -1
9292
}, {
93-
"description": "An unstarted game can not be scored",
93+
"description": "two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike",
94+
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6],
95+
"expected": 26
96+
}, {
97+
"description": "the second bonus rolls after a strike in the last frame can not be a strike if the first one is not a strike",
98+
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6, 10],
99+
"expected": -1
100+
}, {
101+
"description": "an unstarted game can not be scored",
94102
"rolls": [],
95103
"expected": -1
96104
}, {
97-
"description": "An incomplete game can not be scored",
105+
"description": "an incomplete game can not be scored",
98106
"rolls": [0, 0],
99107
"expected": -1
100108
}, {
101-
"description": "A game with more than ten frames can not be scored",
109+
"description": "a game with more than ten frames can not be scored",
102110
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
103111
"expected": -1
104112
}, {

0 commit comments

Comments
 (0)