[plt-scheme] data setup for SchemeUnit tests

From: Christopher Armstrong (radix at twistedmatrix.com)
Date: Sat Jul 29 14:46:53 EDT 2006

(I hope this is the right place to ask this question; I haven't found any
more appropriate forums specific to SchemeUnit).

Say I have a test suite like this:


   (test-equal? "Basic two element pair list"
                (let ([port (open-output-bytes)])
                  (amplify-alist '((#"hi" . #"there") (#"_command" .
#"something")) port)
                  (get-output-bytes port))


   (test-equal? "Empty list"
                (let ([port (open-output-bytes)])
                  (amplify-alist () port)
                  (get-output-bytes port))

The duplication of the definition of `port' is unfortunate, and I'd like to
unify it. I was expecting to be able to do this with before and after
thunks, but since (AFAICT) they're not executed lexically around the test
cases that are run, they can't help here.  #:before and #:after seem only
useful for their side-effects (at least the examples in the documentation
indicate that), and similar for (before) (after) and (around).

Perhaps I'm thinking about this the wrong way or missing something obvious,
because it amazes me that SchemeUnit doesn't have anything to facilitate
this case.  I think what I was expecting is to be able to specify something
like a bindings list that would be evaluated around all tests in a suite.

If this example seems trivial, I have much worse ones; this one serves as a
simple demonstration of my problem.

Thanks for any help.

Christopher Armstrong
International Man of Twistery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20060729/fc429247/attachment.html>

Posted on the users mailing list.