unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 66776@debbugs.gnu.org
Subject: bug#66776: SRFI-64 test-error doesn't match error types
Date: Fri, 27 Oct 2023 14:40:31 -0400	[thread overview]
Message-ID: <878r7nvrhc.fsf@gmail.com> (raw)

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





             reply	other threads:[~2023-10-27 18:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27 18:40 Maxim Cournoyer [this message]
2023-10-28 18:10 ` bug#66776: SRFI-64 test-error doesn't match error types Taylan Kammer
2023-12-12  4:45   ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878r7nvrhc.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=66776@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).