summaryrefslogtreecommitdiff
path: root/lib/all-mills.test.fnl
diff options
context:
space:
mode:
authordozens2024-06-08 20:58:40 -0600
committerdozens2024-06-14 21:52:00 -0600
commit1250f9f057c2e21a0edab87f0a6003a25decd1b7 (patch)
treeb71dbcf18354ebc59bec48ae926654bdf3c0a59b /lib/all-mills.test.fnl
parent91b1662302c14cf84ca8b90c1f3ec20a585f67a5 (diff)
feat: add flying phase
Diffstat (limited to 'lib/all-mills.test.fnl')
-rw-r--r--lib/all-mills.test.fnl41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/all-mills.test.fnl b/lib/all-mills.test.fnl
new file mode 100644
index 0000000..7f33ab1
--- /dev/null
+++ b/lib/all-mills.test.fnl
@@ -0,0 +1,41 @@
+(let [{: describe
+ :end test-end} (require :lib.test)
+ {: all-mills?
+ : toggle-player
+ : only-player-moves
+ : all-moves-are-mills?
+ } (require :lib.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? moves 1)
+ }))
+ (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? moves 1)
+ }))))
+ (test-end))))
+