@@ 1,22 1,27 @@
#!/usr/bin/env bash
# -*- wisp -*-
-guile -L $(dirname $(realpath "$0"))) -c '(import (language wisp spec))'
-exec -a "$0" guile -L $(dirname $(realpath "$0"))) --language=wisp -x .w -e '(d6)' -c '' "$@"
+guile -L $(dirname $(realpath "$0")) -c '(import (language wisp spec))'
+exec -a "$0" guile -L $(dirname $(realpath "$0")) --language=wisp -x .w -e '(d6)' -c '' "$@"
; !#
define-module : d6
. #:export : roll check compete main
use-modules : srfi srfi-1
+ doctests
; basic d6 rules, implemented in guile
define : replace-all vals replacements
. "replace elements in vals that match the car in
replacements by the cdr, in order."
+ ##
+ tests
+ test-equal '(-5 -3 -1 -10 4 6)
+ replace-all '(-5 -3 -1 2 4 6) '((2 . -10))
define : replace val
if : equal? val (caar replacements)
- cadr replacements
+ cdar replacements
. val
cond
: null? replacements
@@ 72,7 77,13 @@ define* : compete skill1 skill2 effect-t
values : >= result1 result2
floor/ {result1 - result2} effect-threshold
+define %this-module : current-module
+define : test
+ doctests-testmod %this-module
+
define : main args
+ when : member "--test" args
+ test
display : check 12 9 3
newline
newline