bug#66776: SRFI-64 test-error doesn't match error types

Maxim Cournoyer <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hello,

I've mean meaning to use 'test-error' in test suites, but as a comment
in its source says, it's currently incomplete:

--8<---------------cut here---------------start------------->8---
;; TODO: decide how to specify expected error types for Guile.
--8<---------------cut here---------------end--------------->8---

So, for example, this should fail but passes:

--8<---------------cut here---------------start------------->8---
(use-modules (srfi srfi-64))
(test-begin "test")
(test-error "testing" 'bad (throw 'oops))
(test-end "test")
--8<---------------cut here---------------end--------------->8---

'test-error' report success for any type of exception, which means its 2nd
argument is currently unused.

It'd also be nice if as its second argument it could accept non only a
error symbol key, but an exception type *or* an exception predicate,
e.g.:

--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 exceptions) (srfi srfi-64))

(define-exception-type &my-exception
  &exception                            ;parent
  make-my-exception                     ;constructor
  my-exception?)                        ;predicate

(test-begin "test-error exception types")

;; Passes, but should fail.
(test-error "&my-exception raised"
  &my-exception
  (raise-exception (make-error)))

;; OR

;; Unimplemented, but passes also.
(test-error "&my-exception raised"
  my-exception?
  (raise-exception (make-error)))

(test-begin "test-error exception types")
--8<---------------cut here---------------end--------------->8---

There is a more modern implementation of SRFI-64 out there for Guile
which may provide clues or be used wholesale, though I haven't tried it:
<https://codeberg.org/taylan/scheme-srfis/src/branch/master/srfi/64>.

-- 
Thanks,
Maxim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.