Re: Brittle exception tests Wolfgang Corcoran-Mathe 16 Jun 2020 19:18 UTC

On 2020-06-16 09:37 +0200, Marc Nieper-Wißkirchen wrote:
> in your test suite, you use your macro `catch-exceptions` in a few places.
> However, it catches every exception so it makes those tests a bit
> meaningless ...

Agreed, it's very brittle.  I'm not sure how to do better, though.

I've reviewed the tests of some other SRFIs for hints.  Those which
use SRFI 64 (e.g. SRFI 146) generally use `test-error' without an
`error-type' argument (the meaning of which is implementation-defined,
anyway), effectively giving a success result if any exception is
raised.  Others (like 135) use `guard' with a single #t clause,
which is another catch-all.

Perhaps `error-object?' could be used meaningfully here:

    (define-syntax catch-errors
      (syntax-rules ()
        ((_ expr)
         (guard (exn ((error-object? exn) 'error)) expr))))

A few tests in Chibi suggest that this doesn't narrow the net much.

I'd appreciate any suggestions for a better way to do this.

Wolfgang Corcoran-Mathe  <>

"In the military more is not better." --_Sun Tzu_