[racket] Pull some rackunit tests into Scribble doc as examples?

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Dec 15 08:34:29 EST 2011

On Thu, Dec 15, 2011 at 7:54 AM, Greg Hendershott
<greghendershott at gmail.com> wrote:
>
> Ideally it would be something like @examples/test-case[
> <test-case-name> ], which strips off the check-* parts, and uses that
> as an expression for a normal Scribble example?

The following (totally untested, written in my email buffer) seems
like the sort of thing you want:

(define-syntax (examples/test-case stx)
  (syntax-parse stx
    [(_ [(~or (~literal check-equal) (~literal check-true)) e:expr
other ...] ...)
     #'(examples expr ...)]))

Of course, you'll need the right evaluator for the examples, and you
might need to handle other `check-blah' forms, but that seems like the
right direction.
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.