@@ -103,6 +103,62 @@ def test_consecutive_stikes_each_get_the_two_roll_bonus(self):
103
103
104
104
self .assertEqual (score , 81 )
105
105
106
+ def test_strike_in_last_frame_gets_two_roll_bonus_counted_once (self ):
107
+ rolls = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 7 , 1 ]
108
+
109
+ self .game = BowlingGame ()
110
+
111
+ for roll in rolls :
112
+ self .game .roll (roll )
113
+ score = self .game .score ()
114
+
115
+ self .assertEqual (score , 18 )
116
+
117
+ def test_rolling_spare_with_bonus_roll_does_not_get_bonus (self ):
118
+ rolls = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 7 , 3 ]
119
+
120
+ self .game = BowlingGame ()
121
+
122
+ for roll in rolls :
123
+ self .game .roll (roll )
124
+ score = self .game .score ()
125
+
126
+ self .assertEqual (score , 20 )
127
+
128
+ def test_strikes_with_the_two_bonus_rolls_do_not_get_bonus_rolls (self ):
129
+ rolls = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 10 , 10 ]
130
+
131
+ self .game = BowlingGame ()
132
+
133
+ for roll in rolls :
134
+ self .game .roll (roll )
135
+ score = self .game .score ()
136
+
137
+ self .assertEqual (score , 30 )
138
+
139
+ def test_strike_with_bonus_after_spare_in_last_frame_gets_no_bonus (self ):
140
+ rolls = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 3 , 10 ]
141
+
142
+ self .game = BowlingGame ()
143
+
144
+ for roll in rolls :
145
+ self .game .roll (roll )
146
+ score = self .game .score ()
147
+
148
+ self .assertEqual (score , 20 )
149
+
150
+ def test_all_strikes_is_a_perfect_game (self ):
151
+
152
+ rolls = [10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 ]
153
+
154
+ self .game = BowlingGame ()
155
+
156
+ for roll in rolls :
157
+ self .game .roll (roll )
158
+ score = self .game .score ()
159
+
160
+ self .assertEqual (score , 300 )
161
+
106
162
107
163
if __name__ == '__main__' :
108
164
unittest .main ()
0 commit comments