On Monday, July 20, 2015 at 5:03:55 PM UTC-7, Jack Firth wrote:
> I'm trying to create a way to automatically turn test cases into examples. 
> I'd like a macro that turns this:
> 
> (extract-expressions
>  (module+ test
>    (check-equal? (extract-expression (square 5)) 25)
>    (check-equal? (extract-expression (square -5)) 25))
>  (module+ doc
>    @defproc[(square [x real?]) real?]{
>      Returns the square of @racket[x], the result of
>      multiplying @racket[x] by itself.
>      @examples[#:eval evaluator (include-extracted-expressions)]}))
> 
> into this:
> 
> (begin
>   (module+ test
>     (check-equal? (square 5) 25))
>   (module+ doc
>     @defproc[(square [x real?]) real?]{
>       Returns the square of @racket[x], the result of
>       multiplying @racket[x] by itself.
>       @examples[#:eval evaluator (square 5) (square -5)]}))
> 
> That's the general idea anyway. I want to be able to gather arbitrary 
> expressions inside a region and "copy" them into some other marked place 
> inside the expressions. How exactly do I go about doing this, and how should 
> I do it "properly"?

Re Alex: I ended up with some functions that just walk the syntax tree and 
strip them out, seemed rather gross but it was all I could think of

Re Matthias: That definitely sounds better, at this stage I'm just fooling 
around with all the possible approaches I can think of to get a better feel for 
how the different forms behave.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to