[plt-scheme] Addition to SchemeUnit?

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

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.