Skip to content

Commit

Permalink
test frame advance
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanmai committed Mar 3, 2012
1 parent e15df57 commit 75cf9b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/kata/bowling.clj
@@ -1,10 +1,12 @@
(ns kata.bowling)

(defn frames [rolls]
(cons (take
(condp #(= 10 (apply + (take %1 %2))) rolls
1 3
2 3
2)
rolls)
[]))
(defn frames
([rolls] (frames rolls frames))
([rolls f]
(cons (take
(condp #(= 10 (apply + (take %1 %2))) rolls
1 3
2 3
2)
rolls)
[])))
8 changes: 7 additions & 1 deletion test/kata/test/bowling.clj
Expand Up @@ -5,5 +5,11 @@
(deftest test-frame-and-bonuses
(are [description frame-and-bonuses rolls] (= frame-and-bonuses (first (frames rolls)))
"strike" '(10 x y) '(10 x y z)
"spare" '( 5 5 x) '( 5 5 x)
"spare" '( 5 5 x) '( 5 5 x y)
"open frame" '( 5 4) '( 5 4 x)))

(deftest test-frame-advance
(are [desciption advance rolls] (= advance (second (frames rolls list)))
"strike" '(x y) '(10 x y z)
"spare" '(x) '( 5 5 x y)
"open frame" '(x) '( 5 4 x)))

0 comments on commit 75cf9b2

Please sign in to comment.