[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SRFI-64: test exception symbol
From: |
Taylan Kammer |
Subject: |
Re: SRFI-64: test exception symbol |
Date: |
Fri, 1 May 2020 11:58:41 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 30.04.2020 17:55, Vladimir Zhbanov wrote:
On Thu, Apr 30, 2020 at 06:06:21PM +0300, Vladimir Zhbanov wrote:
Hi,
In SRFI-64, is there a way to test what exception raised using
test-error() or anything else? I know about looking into test
logs (if 'test-error' is used), though that's not what I need. I
need a way to be sure a test raises the exception it should raise.
The test-error form takes two optional operands before the test
expression. It's defined as:
<start snip>
(test-error [[test-name] error-type] test-expr)
Evaluating test-expr is expected to signal an error. The kind of error
is indicated by error-type.
If the error-type is left out, or it is #t, it means "some kind of
unspecified error should be signaled". For example:
(test-error #t (vector-ref '#(1 2) 9))
This specification leaves it implementation-defined (or for a future
specification) what form test-error may take, though all implementations
must allow #t. Some implementations may support SRFI-35's conditions,
but these are only standardized for SRFI-36's I/O conditions, which are
seldom useful in test suites. An implementation may also allow
implementation-specific "exception types". For example Java-based
implementations may allow the names of Java exception classes:
;; Kawa-specific example
(test-error <java.lang.IndexOutOfBoundsException> (vector-ref '#(1 2) 9))
An implementation that cannot catch exceptions should skip test-error forms.
<end snip>
My SRFI-64 implementation allows the error-type operand to be a
predicate (one-argument procedure that returns a Boolean) to allow
maximum flexibility. It's found here:
https://github.com/TaylanUB/scheme-srfis
- Taylan
- Re: SRFI-64: test exception symbol,
Taylan Kammer <=