add ui tests

main
Dozens B. McCuzzins 2024-06-07 17:27:11 -06:00
parent f985dc4e5c
commit 91b1662302
7 changed files with 62 additions and 2 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
test/*.expect

View File

@ -5,3 +5,7 @@ default:
# run tests # run tests
test: test:
for f in lib/*.test.fnl; do fennel $f | faucet; done 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

View File

@ -72,8 +72,6 @@
2 ;; moving 2 ;; moving
(let [from (index-of-move (string.sub move 1 2)) (let [from (index-of-move (string.sub move 1 2))
to (index-of-move (string.sub move -2 -1))] to (index-of-move (string.sub move -2 -1))]
(print "From" from)
(print "To" to)
(tset self.moves from 0) (tset self.moves from 0)
(tset self.moves to self.player) (tset self.moves to self.player)
(if (mill-at? self.moves to) (if (mill-at? self.moves to)

18
test/README 100644
View File

@ -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?

View File

@ -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

View File

@ -0,0 +1,5 @@
a1
b4
a4
b2
a7

12
test/test.awk 100644
View File

@ -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"
}