summary refs log tree commit diff
path: root/lib/game/all-mills.test.fnl
diff options
context:
space:
mode:
authordozens2024-06-20 09:17:06 -0600
committerdozens2024-06-20 09:17:06 -0600
commitc7b2c982004e350f5e3032321baadfc9021b6bad (patch)
tree3f8883c94bed5a1f847cf60cb11207ca53946c67 /lib/game/all-mills.test.fnl
parentce09973e7cacccdc779f91b8e6e48a520b9f9f4d (diff)
🗄️ big tidy up
- isolate core game logic and move it to src/game.fnl
- main.fnl should be just the ui now
- move all table funcs into lib/table
- move all (1) string funcs into lib/string
- move all game funcs into lib/game/
Diffstat (limited to 'lib/game/all-mills.test.fnl')
-rw-r--r--lib/game/all-mills.test.fnl41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/game/all-mills.test.fnl b/lib/game/all-mills.test.fnl
new file mode 100644
index 0000000..055f6a5
--- /dev/null
+++ b/lib/game/all-mills.test.fnl
@@ -0,0 +1,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))))
+