[plt-scheme] Setup and teardown in SchemeUnit

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Sun Nov 30 18:04:11 EST 2008

Hi,

You could use a macro for abstraction like this (wrote this straight  
into the email - probably contains typos):

   (define-syntax-rule (my-before expr ...)
     (before
       (begin (display "Before") (newline))
       expr ...))

   (test-case "blah"
     (my-before
       (check-equal? 0 0)
       (check-equal? 1 1)
       (check-equal? 2 2)))

The macro can expand to a (test-case ...) form if you want to save  
extra typing.

Hope this helps,

-- Dave

> 2008/11/30 Noel Welsh <noelwelsh at gmail.com>:
>> The before, after, and around macros are the SchemeUnit equivalent.
>
> Let me show you a sample code:
>
> #lang scheme
> (require (planet schematics/schemeunit:3))
> (before
>  (begin (display "Before") (newline))
>  (check-equal? 0 0)
>  (check-equal? 1 1)
>  (check-equal? 2 2))
>
> This displays "Before" only once. Is there a way to tell SchemeUnit to
> invoke setup procedure once for each test (so there would be three
> "Before"s in an example above)?
>
> Cheers,
> mk
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.