Skip to content

bowling: update test data for recent policy changes #1088

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

Merged
merged 3 commits into from
Jan 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 95 additions & 39 deletions exercises/bowling/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"exercise": "bowling",
"version": "1.0.1",
"version": "1.1.0",
"comments": [
"Students should implement roll and score methods.",
"Roll should accept a single integer.",
"Score should return the game's final score, when possible",
"For brevity the tests display all the previous rolls in an array;",
"each element of the previous_rolls array should be passed to the roll method",
"each element of the previousRolls array should be passed to the roll method",
"and each of those previous rolls is expected to succeed.",
"",
"Two properties are tested:",
"",
"`score`: All rolls succeed, and taking the score gives the expected result.",
"The expected result may be an integer score or an error.",
"",
"`roll`: All previous_rolls succeed, and rolling the number of pins in `roll` produces the expected result.",
"`roll`: All previousRolls succeed, and rolling the number of pins in `roll` produces the expected result.",
"Currently, all cases of this type result in errors.",
"",
"In all error cases you should expect an error as is idiomatic for your language",
Expand All @@ -23,150 +23,206 @@
"cases": [{
"description": "should be able to score a game with all zeros",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 0
}, {
"description": "should be able to score a game with no strikes or spares",
"property": "score",
"previous_rolls": [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6],
"input": {
"previousRolls": [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6]
},
"expected": 90
}, {
"description": "a spare followed by zeros is worth ten points",
"property": "score",
"previous_rolls": [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 10
}, {
"description": "points scored in the roll after a spare are counted twice",
"property": "score",
"previous_rolls": [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 16
}, {
"description": "consecutive spares each get a one roll bonus",
"property": "score",
"previous_rolls": [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 31
}, {
"description": "a spare in the last frame gets a one roll bonus that is counted once",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7]
},
"expected": 17
}, {
"description": "a strike earns ten points in a frame with a single roll",
"property": "score",
"previous_rolls": [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 10
}, {
"description": "points scored in the two rolls after a strike are counted twice as a bonus",
"property": "score",
"previous_rolls": [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 26
}, {
"description": "consecutive strikes each get the two roll bonus",
"property": "score",
"previous_rolls": [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"input": {
"previousRolls": [10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"expected": 81
}, {
"description": "a strike in the last frame gets a two roll bonus that is counted once",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1]
},
"expected": 18
}, {
"description": "rolling a spare with the two roll bonus does not get a bonus roll",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3]
},
"expected": 20
}, {
"description": "strikes with the two roll bonus do not get bonus rolls",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10]
},
"expected": 30
}, {
"description": "a strike with the one roll bonus after a spare in the last frame does not get a bonus",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10]
},
"expected": 20
}, {
"description": "all strikes is a perfect game",
"property": "score",
"previous_rolls": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
"input": {
"previousRolls": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
},
"expected": 300
}, {
"description": "rolls cannot score negative points",
"property": "roll",
"previous_rolls": [],
"roll": -1,
"input": {
"previousRolls": [],
"roll": -1
},
"expected": {"error": "Negative roll is invalid"}
}, {
"description": "a roll cannot score more than 10 points",
"property": "roll",
"previous_rolls": [],
"roll": 11,
"input": {
"previousRolls": [],
"roll": 11
},
"expected": {"error": "Pin count exceeds pins on the lane"}
}, {
"description": "two rolls in a frame cannot score more than 10 points",
"property": "roll",
"previous_rolls": [5],
"roll": 6,
"input": {
"previousRolls": [5],
"roll": 6
},
"expected": {"error": "Pin count exceeds pins on the lane"}
}, {
"description": "bonus roll after a strike in the last frame cannot score more than 10 points",
"property": "roll",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10],
"roll": 11,
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10],
"roll": 11
},
"expected": {"error": "Pin count exceeds pins on the lane"}
}, {
"description": "two bonus rolls after a strike in the last frame cannot score more than 10 points",
"property": "roll",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5],
"roll": 6,
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5],
"roll": 6
},
"expected": {"error": "Pin count exceeds pins on the lane"}
}, {
"description": "two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6]
},
"expected": 26
}, {
"description": "the second bonus rolls after a strike in the last frame cannot be a strike if the first one is not a strike",
"property": "roll",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6],
"roll": 10,
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6],
"roll": 10
},
"expected": {"error": "Pin count exceeds pins on the lane"}
}, {
"description": "second bonus roll after a strike in the last frame cannot score more than 10 points",
"property": "roll",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10],
"roll": 11,
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10],
"roll": 11
},
"expected": {"error": "Pin count exceeds pins on the lane"}
}, {
"description": "an unstarted game cannot be scored",
"property": "score",
"previous_rolls": [],
"input": {
"previousRolls": []
},
"expected": {"error": "Score cannot be taken until the end of the game"}
}, {
"description": "an incomplete game cannot be scored",
"property": "score",
"previous_rolls": [0, 0],
"input": {
"previousRolls": [0, 0]
},
"expected": {"error": "Score cannot be taken until the end of the game"}
}, {
"description": "cannot roll if game already has ten frames",
"property": "roll",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"roll": 0,
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"roll": 0
},
"expected": {"error": "Cannot roll after game is over"}
}, {
"description": "bonus rolls for a strike in the last frame must be rolled before score can be calculated",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]
},
"expected": {"error": "Score cannot be taken until the end of the game"}
}, {
"description": "both bonus rolls for a strike in the last frame must be rolled before score can be calculated",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10]
},
"expected": {"error": "Score cannot be taken until the end of the game"}
}, {
"description": "bonus roll for a spare in the last frame must be rolled before score can be calculated",
"property": "score",
"previous_rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3],
"input": {
"previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3]
},
"expected": {"error": "Score cannot be taken until the end of the game"}
}]
}