1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

(run-test-exception): Add special handling for

`error'-generated exceptions, which pass key
`misc-error' and leave messages unformatted.
This commit is contained in:
Thien-Thi Nguyen 2001-08-01 09:57:01 +00:00
parent 9ebd6e6281
commit bba2d1908a

View file

@ -288,9 +288,20 @@
(stack-catch (car exception)
(lambda () (thunk) #f)
(lambda (key proc message . rest)
(if (not (string-match (cdr exception) message))
(apply throw key proc message rest)
#t))))))
(cond
;; handle explicit key
((string-match (cdr exception) message)
#t)
;; handle `(error ...)' which uses `misc-error' for key and doesn't
;; yet format the message and args (we have to do it here).
((and (eq? 'misc-error (car exception))
(list? rest)
(string-match (cdr exception)
(apply simple-format #f message (car rest))))
#t)
;; unhandled; throw again
(else
(apply throw key proc message rest))))))))
;;; A short form for tests that expect a certain exception to be thrown.
(defmacro pass-if-exception (name exception body . rest)