1 files changed, 29 insertions(+), 13 deletions(-)

M doctests.scm
M doctests.scm +29 -13
@@ 1,6 1,7 @@ 
-#!/usr/bin/env sh
-# -*- scheme -*-
-exec guile -L $(dirname $(dirname $(realpath "$0"))) -e '(@@ (examples doctests) main)' -s "$0" "$@"
+#!/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 '(doctests)' -c '' "$@")
 ; !#
 
 ;;; doctests --- simple testing by adding procedure-properties with tests.

          
@@ 38,14 39,13 @@ exec guile -L $(dirname $(dirname $(real
 ;;     #((tests (test-eqv 'A (A))))
 ;;     #f)
 
-;; With wisp, you currently need to use the literal
-;; ##
-;;    tests
-;;        test-equal ...
+;; With wisp, you currently need to use the literal #((tests (...)))
+;; TODO: add array parsing to wisp following quoting with ':
+;;       # a b → #(a b) and # : a b c → #((a b))
 
 
 (define-module (doctests)
-              #:export (doctests-testmod))
+              #:export (doctests-testmod main))
 
 (import (ice-9 optargs)
          (ice-9 rdelim)

          
@@ 98,14 98,16 @@ exec guile -L $(dirname $(dirname $(real
 
 (define (subtract a b)
     "Subtract B from A."
-    #((tests (test-eqv 3 (subtract 5 2))))
+    #(
+      (tests (test-eqv 3 (subtract 5 2))))
     (- a b))
 
 (define (doctests-testmod mod)
        "Execute all doctests in the current module
 
           This procedure provides an example test:"
-       #((tests 
+       #(
+         (tests
             ('mytest
               (define v (make-vector 5 99))
               (test-assert (vector? v))

          
@@ 142,10 144,15 @@ exec guile -L $(dirname $(dirname $(real
                                  (testid
                                     (match doctest
                                       (((('quote id) tests ...) moretests ...)
-                                        (string-join (list filename (symbol->string name) (symbol->string id))
-                                                     "--"))
+                                        (string-join
+                                            (list filename 
+                                                ;; escape / in paths
+                                                (string-join (string-split (symbol->string name) #\/ ) "--")
+                                                (symbol->string id))
+                                            "--"))
                                       ((tests ...)
-                                        (string-join (list filename (symbol->string name))
+                                        ;; escape / in paths
+                                        (string-join (list filename (string-join (string-split (symbol->string name) #\/ ) "--"))
                                                      "--"))))
                                  (body
                                      (match doctest

          
@@ 176,6 183,15 @@ exec guile -L $(dirname $(dirname $(real
                                         #t))))))
                    (loop (cdr names) (cdr doctests))))))
 
+(define (hello who)
+    "Say hello to WHO"
+    #(
+        (tests
+            (test-equal "Hello World!\n"
+                       (hello "World"))))
+    (format #f "Hello ~a!\n"
+                   who))
+
 (define %this-module (current-module))
 (define (main args)
          (doctests-testmod %this-module))