summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--justfile4
-rw-r--r--main.fnl2
-rw-r--r--test/README18
-rw-r--r--test/moving-capture.dat22
-rw-r--r--test/placing-capture.dat5
-rw-r--r--test/test.awk12
7 files changed, 62 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae062d0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+test/*.expect
diff --git a/justfile b/justfile
index 6fbee75..e5fa402 100644
--- a/justfile
+++ b/justfile
@@ -5,3 +5,7 @@ default:
 # run tests
 test:
   for f in lib/*.test.fnl; do fennel $f | faucet; done
+
+# build expect scripts
+expects:
+  for f in test/*.dat; do awk -f test/test.awk $f > ${f/dat/expect}; done
diff --git a/main.fnl b/main.fnl
index af23d90..bf6933e 100644
--- a/main.fnl
+++ b/main.fnl
@@ -72,8 +72,6 @@
       2 ;; moving
         (let [from (index-of-move (string.sub move 1 2))
               to  (index-of-move (string.sub move -2 -1))]
-            (print "From" from)
-            (print "To" to)
             (tset self.moves from 0)
             (tset self.moves to self.player)
             (if (mill-at? self.moves to)
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..11b09a4
--- /dev/null
+++ b/test/README
@@ -0,0 +1,18 @@
+== ABOUT ==
+
+these files are to help me test the ui
+
+moves are recorded in `<file>.dat`.
+then you can `awk -f test.awk file.dat > file.expect`.
+(or `just expects` to build them all.)
+then you can `expect file.expect`
+to have expect play the game for you up to a certain point.
+
+== REQUIREMENTS ==
+
+- awk
+- expect
+
+== FUTURE PLANS ==
+
+have actual integration tests?
diff --git a/test/moving-capture.dat b/test/moving-capture.dat
new file mode 100644
index 0000000..d19ede6
--- /dev/null
+++ b/test/moving-capture.dat
@@ -0,0 +1,22 @@
+A1
+A4
+A7
+b2
+b4
+b6
+c3
+c4
+c5
+d1
+d2
+d3
+d5
+d6
+d7
+e3
+e4
+e5
+e4f4
+e3e4
+f4g4
+d3e3
diff --git a/test/placing-capture.dat b/test/placing-capture.dat
new file mode 100644
index 0000000..67aebec
--- /dev/null
+++ b/test/placing-capture.dat
@@ -0,0 +1,5 @@
+a1
+b4
+a4
+b2
+a7
diff --git a/test/test.awk b/test/test.awk
new file mode 100644
index 0000000..ef6df20
--- /dev/null
+++ b/test/test.awk
@@ -0,0 +1,12 @@
+BEGIN {
+  print "#!/usr/bin/expect -f"
+  print "spawn fennel main.fnl"
+}
+
+{ print "expect -re \"Player .'s turn:\""
+  print "send -- \"" $0 "\\r\""
+}
+
+END {
+  print "interact"
+}