summary refs log tree commit diff
path: root/lib/game/all-mills.test.fnl
blob: 055f6a55c1b92706367ec0843d33a898f53b64ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(let [{: describe
       : test-end} (require :lib.test)
      {: all-mills?
       : toggle-player
       : only-player-moves
       : all-moves-are-mills?
       } (require :lib.game.all-mills)]

  (describe "# ALL-MILLS" (fn []
    (describe "toggle-player()" (fn [t]
      (t {:given "a player"
          :should "return the next"
          :expected 2
          :actual (toggle-player 1)
          })))
    (describe "only-player-moves()" (fn [t]
      (let [moves    [ 0 2 0 2 2 2 0 0 0 0 0 0 0 2 0 0 0 2 0 2 0 1 1 1 ]
            expected [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 ]
            ]
        (t {:given "a bunch of moves and a player"
            :should "filter out all the moves not belonging to the player"
            : expected
            :actual (only-player-moves moves 1)
            }))))
    (describe "all-moves-are-mills?()" (fn [t]
      (let [moves [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 ]
            ]
        (t {:given "a bunch of moves and a player"
            :should "return true if all the player moves are mills"
            :expected true
            :actual (all-moves-are-mills? 1 moves)
            }))
      (let [moves [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ]
            ]
        (t {:given "a bunch of moves and no mill and a player"
            :should "return false"
            :expected false
            :actual (all-moves-are-mills? 1 moves)
            }))))
    (test-end))))