[racket] How to write a unit test for syntax-parse expectation failure error message?

From: Greg Hendershott (greghendershott at gmail.com)
Date: Sun Dec 2 12:14:56 EST 2012

I'd like to write a unit test that a syntax-parse expectation failure
elicits a certain error message. For instance, I'd do a regexp-match?
that "something" is present in a message like "expected something".

However it seems that syntax-parse expectation failures don't raise an
exception. In other words, this will never return 'caught:

(with-handlers ([exn? (lambda (exn) 'caught)])
  something-that-elicits-a-syntax-parse-expectation-failure)

(At first I'd tried exn:syntax?, and when that didn't work, I checked
to see if it was any kind of exception. Seems not.)

Is there another way to go about this?

p.s. Having such a unit test would be a nice-to-have, not
must-have. So if this can't be done, that's fine. I just wanted to
double-check if there's some way.

Posted on the users mailing list.