@@ -12,7 +12,7 @@ defmodule BowlingTest do
12
12
Enum . reduce ( rolls , game , fn ( roll , game ) -> Bowling . roll ( game , roll ) end )
13
13
end
14
14
15
- test "can score all 0s " do
15
+ test "should be able to score a game with all zeros " do
16
16
game = Bowling . start
17
17
rolls = [ 0 , 0 ,
18
18
0 , 0 ,
@@ -29,7 +29,7 @@ defmodule BowlingTest do
29
29
end
30
30
31
31
@ tag :pending
32
- test "can score a game with no strikes or spares" do
32
+ test "should be able to score a game with no strikes or spares" do
33
33
game = Bowling . start
34
34
rolls = [ 3 , 6 ,
35
35
3 , 6 ,
@@ -46,7 +46,7 @@ defmodule BowlingTest do
46
46
end
47
47
48
48
@ tag :pending
49
- test "spare followed by all 0s is worth 10 points" do
49
+ test "a spare followed by zeros is worth ten points" do
50
50
game = Bowling . start
51
51
rolls = [ 6 , 4 ,
52
52
0 , 0 ,
@@ -63,7 +63,7 @@ defmodule BowlingTest do
63
63
end
64
64
65
65
@ tag :pending
66
- test "points scored in the roll after the spare are counted twice" do
66
+ test "points scored in the roll after a spare are counted twice" do
67
67
game = Bowling . start
68
68
rolls = [ 6 , 4 ,
69
69
3 , 0 ,
@@ -115,7 +115,7 @@ defmodule BowlingTest do
115
115
end
116
116
117
117
@ tag :pending
118
- test "a strike earns ten points in frame with a single roll" do
118
+ test "a strike earns ten points in a frame with a single roll" do
119
119
game = Bowling . start
120
120
rolls = [ 10 ,
121
121
0 , 0 ,
@@ -258,26 +258,26 @@ defmodule BowlingTest do
258
258
end
259
259
260
260
@ tag :pending
261
- test "rolls can not score negative points" do
261
+ test "rolls cannot score negative points" do
262
262
game = Bowling . start
263
- assert Bowling . roll ( game , - 1 ) == { :error , "Pins must have a value from 0 to 10 " }
263
+ assert Bowling . roll ( game , - 1 ) == { :error , "Negative roll is invalid " }
264
264
end
265
265
266
266
@ tag :pending
267
- test "a roll can not score more than 10 points" do
267
+ test "a roll cannot score more than 10 points" do
268
268
game = Bowling . start
269
- assert Bowling . roll ( game , 11 ) == { :error , "Pins must have a value from 0 to 10 " }
269
+ assert Bowling . roll ( game , 11 ) == { :error , "Pin count exceeds pins on the lane " }
270
270
end
271
271
272
272
@ tag :pending
273
- test "two rolls in a frame can not score more than 10 points" do
273
+ test "two rolls in a frame cannot score more than 10 points" do
274
274
game = Bowling . start
275
275
game = Bowling . roll ( game , 5 )
276
276
assert Bowling . roll ( game , 6 ) == { :error , "Pin count exceeds pins on the lane" }
277
277
end
278
278
279
279
@ tag :pending
280
- test "two bonus rolls after a strike in the last frame can not score more than 10 points" do
280
+ test "bonus roll after a strike in the last frame cannot score more than 10 points" do
281
281
game = Bowling . start
282
282
rolls = [ 0 , 0 ,
283
283
0 , 0 ,
@@ -288,26 +288,100 @@ defmodule BowlingTest do
288
288
0 , 0 ,
289
289
0 , 0 ,
290
290
0 , 0 ,
291
+ 10 ]
292
+ game = roll_reduce ( game , rolls )
293
+ assert Bowling . roll ( game , 11 ) == { :error , "Pin count exceeds pins on the lane" }
294
+ end
295
+
296
+ @ tag :pending
297
+ test "two bonus rolls after a strike in the last frame cannot score more than 10 points" do
298
+ game = Bowling . start
299
+ rolls = [ 0 , 0 ,
300
+ 0 , 0 ,
301
+ 0 , 0 ,
302
+ 0 , 0 ,
303
+ 0 , 0 ,
304
+ 0 , 0 ,
305
+ 0 , 0 ,
306
+ 0 , 0 ,
307
+ 0 , 0 ,
308
+ 10 ,
291
309
5 ]
292
310
game = roll_reduce ( game , rolls )
293
311
assert Bowling . roll ( game , 6 ) == { :error , "Pin count exceeds pins on the lane" }
294
312
end
295
313
296
314
@ tag :pending
297
- test "an unstarted game can not be scored" do
315
+ test "two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike" do
316
+ game = Bowling . start
317
+ rolls = [ 0 , 0 ,
318
+ 0 , 0 ,
319
+ 0 , 0 ,
320
+ 0 , 0 ,
321
+ 0 , 0 ,
322
+ 0 , 0 ,
323
+ 0 , 0 ,
324
+ 0 , 0 ,
325
+ 0 , 0 ,
326
+ 10 ,
327
+ 10 ,
328
+ 6 ]
329
+ game = roll_reduce ( game , rolls )
330
+ assert Bowling . score ( game ) == 26
331
+ end
332
+
333
+ @ tag :pending
334
+ test "the second bonus rolls after a strike in the last frame cannot be a strike if the first one is not a strike" do
335
+ game = Bowling . start
336
+ rolls = [ 0 , 0 ,
337
+ 0 , 0 ,
338
+ 0 , 0 ,
339
+ 0 , 0 ,
340
+ 0 , 0 ,
341
+ 0 , 0 ,
342
+ 0 , 0 ,
343
+ 0 , 0 ,
344
+ 0 , 0 ,
345
+ 10 ,
346
+ 6 ]
347
+ game = roll_reduce ( game , rolls )
348
+ assert Bowling . roll ( game , 10 ) == { :error , "Pin count exceeds pins on the lane" }
349
+ end
350
+
351
+ @ tag :pending
352
+ test "second bonus roll after a strike in the last frame cannot score more than 10 points" do
353
+ game = Bowling . start
354
+ rolls = [ 0 , 0 ,
355
+ 0 , 0 ,
356
+ 0 , 0 ,
357
+ 0 , 0 ,
358
+ 0 , 0 ,
359
+ 0 , 0 ,
360
+ 0 , 0 ,
361
+ 0 , 0 ,
362
+ 0 , 0 ,
363
+ 10 ,
364
+ 10 ]
365
+ game = roll_reduce ( game , rolls )
366
+ assert Bowling . roll ( game , 11 ) == { :error , "Pin count exceeds pins on the lane" }
367
+ end
368
+
369
+ @ tag :pending
370
+ test "an unstarted game cannot be scored" do
298
371
game = Bowling . start
299
372
assert Bowling . score ( game ) == { :error , "Score cannot be taken until the end of the game" }
300
373
end
301
374
302
375
@ tag :pending
303
- test "score cannot be taken until the end of the game " do
376
+ test "an incomplete game cannot be scored " do
304
377
game = Bowling . start
305
- game = Bowling . roll ( game , 0 )
378
+ rolls = [ 0 , 0 ]
379
+ game = roll_reduce ( game , rolls )
306
380
assert Bowling . score ( game ) == { :error , "Score cannot be taken until the end of the game" }
307
381
end
308
382
309
383
@ tag :pending
310
- test "a game with more than ten frames can not be scored " do
384
+ test "cannot roll if game already has ten frames" do
311
385
game = Bowling . start
312
386
rolls = [ 0 , 0 ,
313
387
0 , 0 ,
@@ -318,10 +392,9 @@ defmodule BowlingTest do
318
392
0 , 0 ,
319
393
0 , 0 ,
320
394
0 , 0 ,
321
- 0 , 0 ,
322
- 0 ]
395
+ 0 , 0 ]
323
396
game = roll_reduce ( game , rolls )
324
- assert Bowling . score ( game ) == { :error , "Invalid game: too many frames " }
397
+ assert Bowling . roll ( game , 0 ) == { :error , "Cannot roll after game is over " }
325
398
end
326
399
327
400
@ tag :pending
0 commit comments