From ce09973e7cacccdc779f91b8e6e48a520b9f9f4d Mon Sep 17 00:00:00 2001 From: dozens Date: Sat, 15 Jun 2024 21:15:59 -0600 Subject: feat: add end game --- lib/no-moves.test.fnl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/no-moves.test.fnl (limited to 'lib/no-moves.test.fnl') diff --git a/lib/no-moves.test.fnl b/lib/no-moves.test.fnl new file mode 100644 index 0000000..db0613c --- /dev/null +++ b/lib/no-moves.test.fnl @@ -0,0 +1,51 @@ +(let [{: no-moves?} (require :lib.no-moves) + {: neighbors} (require :lib.constants) + {: describe :end test-end} (require :lib.test) + with-neighbors (partial no-moves? neighbors) + ] + + (describe "no-moves()" (fn [t] + (let [moves [ 1 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 ] + player 1 + ] + (t {:given "one move with no moves" + :should "return true" + :expected true + :actual (with-neighbors moves player) + })) + (let [moves [ 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] + player 1 + ] + (t {:given "one move with one move" + :should "return false" + :expected false + :actual (with-neighbors moves player) + })) + (let [moves [ 1 1 1 0 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 0 0 0 ] + player 1 + ] + (t {:given "several moves with no moves" + :should "return true" + :expected true + :actual (with-neighbors moves player) + })) + (let [moves [ 0 2 0 2 1 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] + player 1 + ] + (t {:given "four occupied neighbors" + :should "return true" + :expected true + :actual (with-neighbors moves player) + })) + (let [moves [ 1 2 1 2 0 2 1 2 1 2 1 0 1 2 1 2 2 2 0 1 0 0 0 0 0 ] + player 2 + ] + (t {:given "this turn that is giving me trouble" + :should "return true" + :expected true + :actual (with-neighbors moves player) + })) + + (test-end)))) + + -- cgit 1.4.1-2-gfad0