[plt-scheme] Re: Addition to SchemeUnit?

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Tue Dec 22 17:45:03 EST 2009

For those who care, I can't use (check-expect ...) et al because I'm
checking side effects, like whether a file is created, and since the
check-expects get saved up till the end, I'd have to evaluate the
expressions myself, save the values, and check-expect those. (I


On Tue, Dec 22, 2009 at 5: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
>  (syntax-rules ()
>    [(_ expr msg)
>     (check-exn (lambda (e) (and (exn? e)
>                                 (string=? (exn-message e) msg)))
>                (lambda () expr))]
>    [(_ expr msg output)
>     (check-exn (lambda (e) (and (exn? e)
>                                 (string=? (exn-message e) msg)))
>                (lambda () expr)
>                output)]))
> 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.
> Todd

Posted on the users mailing list.