[plt-scheme] Addition to SchemeUnit?

From: Noel Welsh (noelwelsh at gmail.com)
Date: Wed Dec 23 11:19:06 EST 2009

On Tue, Dec 22, 2009 at 10:42 PM, Todd O'Bryan <toddobryan at gmail.com> wrote:
> In the spirit of the test-engine's (check-error ...), which lets you
> check for the exception's message, I just defined this macro:
> (define-syntax check-exn-msg ...)
> It has the advantage over (check-exn ...) that you don't have to put
> the expression in a thunk and you can just put the expected message,
> rather than having to write a predicate about the expected exception.
> So...
> Is this a bad idea? Before I write a bunch of tests using this, I want
> to make sure that I'm not going to be bitten in the butt later.

Looks fine to me. Checks are meant to operate like functions, which is
why you have to use the thunk in check-exn. A bunch of people have
complained about this. I can see their point but I like the clean
model, so I'm a bit torn. I could be persuaded to change check-exn.

I prefer checking the type of the exn rather than the error message.
I.e. I tend to use a deeper exn hierarchy when I want to convey
information on the error. This enables more flexible output than just
using the message string. With the message string you're stuck with
whatever it contains, which is not appropriate in all situations
(think help a programmer debug vs presenting information to a user).


Posted on the users mailing list.