unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#24647: SRFI 64 − Test marked as passed when it should have been marked as fail
@ 2016-10-09 15:58 Amirouche Boubekki
  2017-01-30 19:38 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Amirouche Boubekki @ 2016-10-09 15:58 UTC (permalink / raw)
  To: 24647

The code for SRFI-64 does implement error catching, but that it might 
return #f if an error happens causing a passed test when it should have 
been marked as FAIL

(use-modules (srfi srfi-64))

(test-begin "repository")

(test-equal
     #f
   (throw 'key))

(test-end)






^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#24647: SRFI 64 − Test marked as passed when it should have been marked as fail
  2016-10-09 15:58 bug#24647: SRFI 64 − Test marked as passed when it should have been marked as fail Amirouche Boubekki
@ 2017-01-30 19:38 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-01-30 19:38 UTC (permalink / raw)
  To: Amirouche Boubekki; +Cc: 24647

Hi,

Amirouche Boubekki <amirouche@hypermove.net> skribis:

> The code for SRFI-64 does implement error catching, but that it might
> return #f if an error happens causing a passed test when it should
> have been marked as FAIL
>
> (use-modules (srfi srfi-64))
>
> (test-begin "repository")
>
> (test-equal
>     #f
>   (throw 'key))
>
> (test-end)

It may look surprising, but I think it’s intended (although the SRFI
document does not explicitly say so.)  First, the generate log file
reads:

--8<---------------cut here---------------start------------->8---
Test begin:
  test-name: "foo"
  source-file: "/home/ludo/src/guile/t.scm"
  source-line: 5
  source-form: (test-equal "foo" #f (throw (quote key)))
Test end:
  result-kind: pass
  actual-value: #f
  actual-error: (key)
  expected-value: #f
--8<---------------cut here---------------end--------------->8---

… which clearly shows that the exception was caught, but that the test
was considered a success because the actual value of #f matches the
expected value.  Second, SRFI-64 uses ‘%test-evaluate-with-catch’, whose
name makes the intent quite clear.

So I think you should be using ‘test-assert’ in this case, like this:

  (test-assert "foo"
    (throw 'key))

This is correctly flagged as a failure.

Thanks,
Ludo’.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-30 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-09 15:58 bug#24647: SRFI 64 − Test marked as passed when it should have been marked as fail Amirouche Boubekki
2017-01-30 19:38 ` Ludovic Courtès

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).