From: "Jérémy Korwin-Zmijowski" <jeremy@korwin-zmijowski.fr>
To: srfi-64@srfi.schemers.org, Mailing list Guile User <guile-user@gnu.org>
Subject: test-equal: actual returned value is #f when tested expression raises execption
Date: Sat, 20 Feb 2021 12:03:21 +0100 [thread overview]
Message-ID: <e15e635b612f75cfb14675ac07453d6fb40934e3.camel@korwin-zmijowski.fr> (raw)
Dear Schemers,
As a Guile user, I rely mostly on srfi-64 to write tests.
Recently, a Guile fellow pointed out a strange behavior from one of my
code :
Say I write a test suite :
;; char-sets-test.scm
(use-modules (srfi srfi-64)
(char-sets))
(test-begin "harness-char-sets")
(test-equal "empty password is not valid"
#f
(password-valid? ""))
(test-end "harness-char-sets")
Running `guile -L . char-sets-test.scm` in the file location will
produce the following output :
$ guile -L . char-sets-test.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/char-sets-test.scm
;;; WARNING: compilation of /tmp/char-sets-test.scm failed:
;;; no code for module (char-sets)
Backtrace:
9 (primitive-load "/tmp/char-sets-test.scm")
In ice-9/eval.scm:
721:20 8 (primitive-eval (use-modules (srfi srfi-64) (char-
sets)))
In ice-9/psyntax.scm:
1241:36 7 (expand-top-sequence ((use-modules (srfi srfi-64) (#)))
…)
1233:19 6 (parse _ (("placeholder" placeholder)) ((top) #(# # …))
…)
285:10 5 (parse _ (("placeholder" placeholder)) (()) _ c&e
(eval) …)
In ice-9/boot-9.scm:
3898:20 4 (process-use-modules _)
222:29 3 (map1 (((srfi srfi-64)) ((char-sets))))
222:17 2 (map1 (((char-sets))))
3899:31 1 (_ ((char-sets)))
3300:6 0 (resolve-interface (char-sets) #:select _ #:hide _ # _
# …)
ice-9/boot-9.scm:3300:6: In procedure resolve-interface:
no code for module (char-sets)
All good so far. Then I create the `(char-sets)` module in a file next
to the test file :
;; char-sets.scm
(define-module (char-sets))
And now, I rerun the tests :
$ guile -L . char-sets-test.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/char-sets-test.scm
;;; compiling ./char-sets.scm
;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char-
sets.scm.go
;;; char-sets-test.scm:10:2: warning: possibly unbound variable
`password-valid?'
;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char-sets-
test.scm.go
%%%% Starting test harness-char-sets (Writing full log to "harness-
char-sets.log")
# of expected passes 1
Here, the result of the test feel weird to me. As the tested procedure
is not defined I was expecting the test to fail.
Is there a way to get a failing test in such situation ? I fear to miss
things like those and so build non working softwares.
Cheers,
Jérémy
next reply other threads:[~2021-02-20 11:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-20 11:03 Jérémy Korwin-Zmijowski [this message]
2021-02-20 11:26 ` test-equal: actual returned value is #f when tested expression raises execption divoplade
2021-02-20 12:09 ` Jérémy Korwin-Zmijowski
2021-02-21 14:21 ` Taylan Kammer
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=e15e635b612f75cfb14675ac07453d6fb40934e3.camel@korwin-zmijowski.fr \
--to=jeremy@korwin-zmijowski.fr \
--cc=guile-user@gnu.org \
--cc=srfi-64@srfi.schemers.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).