Changeset 12656 in project


Ignore:
Timestamp:
11/29/08 20:08:22 (13 years ago)
Author:
azul
Message:

Better support for defining unit tests in a wiki file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/svnwiki-chicken/trunk/svnwiki-chicken.scm

    r12533 r12656  
    6262
    6363(define (chicken-examples env)
    64   (let-from-environment env (params parse text)
    65     (parse
    66       (html-stream
    67         "Examples:\n\n"
    68         "<enscript highlight=scheme>" (parse text) "</enscript>"))))
     64  (let-from-environment env (params parse text output-format)
     65    (let ((filename (assoc 'filename params))
     66          (group (assoc 'testgroup params)))
     67      (if (or (not (eq? output-format 'enscript))
     68              (and filename group))
     69        (parse
     70          (html-stream
     71            "Examples:\n\n"
     72            "<enscript highlight=scheme"
     73            (if (and filename group)
     74              (format #f " filename='~A'"
     75                      (stream->string
     76                        (stream-remove (cut char=? <> #\')
     77                                       (cdr filename))))
     78              "")
     79            ">"
     80            (if (and filename group (eq? output-format 'enscript))
     81              (format #f "(test-group ~A" (stream->string (cdr group)))
     82              "")
     83            (parse text)
     84            (if (and filename group (eq? output-format 'enscript))
     85              ")\n"
     86              "")
     87            "</enscript>"))
     88        stream-null))))
     89
     90(define (chicken-example env)
     91  (let-from-environment env (text output-format parse)
     92    (html-stream
     93      (if (eq? output-format 'enscript)
     94        "\n  (test "
     95        "")
     96      (parse text)
     97      (if (eq? output-format 'enscript)
     98        ")"
     99        ""))))
    69100
    70101(define (chicken-expr env)
    71   (let-from-environment env (text)
    72     (html-stream text "\n")))
     102  (let-from-environment env (text output-format)
     103    (if (eq? output-format 'enscript)
     104      (html-stream " " text)
     105      (html-stream text "\n"))))
    73106
    74 (define (chicken-result prefix env)
    75   (let-from-environment env (text)
    76     (html-stream prefix " " text "\n")))
     107(define (chicken-result include prefix env)
     108  (let-from-environment env (text output-format)
     109    (if (eq? output-format 'enscript)
     110      (html-stream prefix " " text)
     111      (html-stream prefix " " text "\n"))))
     112
     113(define (chicken-result-cmp include prefix env)
     114  (let-from-environment env (text output-format)
     115    (if (eq? output-format 'enscript)
     116      (html-stream prefix " " text)
     117      stream-null)))
    77118
    78119(svnwiki-extension-define 'code-break 'chickenegg chicken-egg-html)
     
    86127(svnwiki-extension-define 'code-span 'method (cut chicken-def "method" <>))
    87128(svnwiki-extension-define 'code-span 'examples chicken-examples)
     129(svnwiki-extension-define 'code-span 'example chicken-example)
    88130(svnwiki-extension-define 'code-span 'expr chicken-expr)
    89 (svnwiki-extension-define 'code-span 'result (cut chicken-example "=>" <>))
    90 (svnwiki-extension-define 'code-span 'input (cut chicken-example "[input]" <>))
    91 (svnwiki-extension-define 'code-span 'output (cut chicken-example "[output]" <>))
     131(svnwiki-extension-define 'code-span 'result (cut chicken-result #t "=>" <>))
     132(svnwiki-extension-define 'code-span 'resultcmp chicken-result-cmp)
     133(svnwiki-extension-define 'code-span 'input (cut chicken-result #f "[input]" <>))
     134(svnwiki-extension-define 'code-span 'output (cut chicken-result #f "[output]" <>))
Note: See TracChangeset for help on using the changeset viewer.