SchemeUnit: proposed syntax and perspective changes

Ryan Michael Culpepper <[email protected]> Mon, 14 Feb 2005 10:57:11 -0500 (EST)
Newsgroups gmane.lisp.scheme.plt.schematics
Message-ID <[email protected]>
Right now a test case with setup and teardown actions looks like this:

(make-test-case "name"
  some-code
  ___
  'setup setup-thunk
  ___
  'teardown teardown-thunk
  ___)

Writing a macro to correctly handle this syntax is not easy, and the
current implementation is wrong (it breaks badly on macros that expand
into test cases).

There are a couple different things we can do. First, we can keep the
existing setup and teardown concepts but change the syntax to:

(make-test-case "name"
  ___
  (setup code ...)
  ___
  (teardown code ...)
  ___)

Here setup and teardown would be keywords provided from test.ss. This
macro is fairly easy to write.

Another option is to change perspective from "before/after" to "around":
let them supply a procedure that wraps execution of the test.

(make-test-case "name"
  (around (lambda (go) (parameterize ((current-directory "there")) (go)))
  code ...)

This is nicer in some ways, and the macro is just as easy, but
implementing this correctly makes me worried. I'll have to think about it
more.

The final approach is to eliminate special syntax and special notions of
test prep and strike entirely and advice the users to write their own
with-handlers and dynamic-wind expressions. We can move the concept out of
the test framework into the tests, and then we can write regular
abstractions (procedures and macros) over the common cases.

I favor the last approach, I think.

Ryan


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click