unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: Guile User <guile-user@gnu.org>
Subject: srfi-64 tests passing when they should not
Date: Tue,  4 May 2021 08:31:38 +0000	[thread overview]
Message-ID: <40a496bb-c005-3c6f-2bf2-7025f3a234bb@posteo.de> (raw)

Hello Guile users!

I noticed something strange about SRFI-64 unit tests, when using test-equal with
an expected result of false (#f):

~~~~
(import
  ;; unit tests
  (srfi srfi-64)
  ;; module to test
  (list-utils))


(test-begin "list-utils-test")

(test-group
 "list-prefixes-test"

 (test-equal "gives all list prefixes -- 00"
   '(("static") ("static" "img"))
   (list-prefixes '("static" "img" "logo.png")))

 (test-equal "gives false for one element lists -- 00"
   #f
   (list-prefixes '("static")))

 (test-assert "gives false for zero element lists -- 00"
   (equal? #f (list-prefixes '()))))

(test-end "list-utils-test")
~~~~

This code is for a still empty module (not even a module defined in that
(list-utils) file. So I expect all tests to fail, due to the error of unbound
variables.

However, the result is surprisingly 2 passing tests, despite errors happening
during the test:

~~~~
%%%% Starting test list-utils-test
Group begin: list-utils-test
Group begin: list-prefixes-test
Test begin:
  test-name: "gives all list prefixes -- 00"
  source-file: "test/test-list-utils.scm"
  source-line: 13
  source-form: (test-equal "gives all list prefixes -- 00" (quote (("static") ("static" "img"))) (list-prefixes (quote ("static" "img" "logo.png"))))
Test end:
  result-kind: fail
  actual-value: #f
  actual-error: (unbound-variable #f "Unbound variable: ~S" (list-prefixes) #f)
  expected-value: (("static") ("static" "img"))
Test begin:
  test-name: "gives false for one element lists -- 00"
  source-file: "test/test-list-utils.scm"
  source-line: 17
  source-form: (test-equal "gives false for one element lists -- 00" #f (list-prefixes (quote ("static"))))
Test end:
  result-kind: pass
  actual-value: #f
  actual-error: (unbound-variable #f "Unbound variable: ~S" (list-prefixes) #f)
  expected-value: #f
Test begin:
  test-name: "gives false for zero element lists -- 00"
  source-file: "test/test-list-utils.scm"
  source-line: 21
  source-form: (test-equal "gives false for zero element lists -- 00" #f (list-prefixes (quote ())))
Test end:
  result-kind: pass
  actual-value: #f
  actual-error: (unbound-variable #f "Unbound variable: ~S" (list-prefixes) #f)
  expected-value: #f
Group end: list-prefixes-test
Group end: list-utils-test
# of expected passes      2
# of unexpected failures  1
~~~~

The first 2 tests are surprisingly passing. This is also the reason, why I used
test-assert and manually wrote the (equal? ...) in the last test, to see,
whether it makes any difference. Indeed it does.

Why does die implementation behave like this?

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




             reply	other threads:[~2021-05-04  8:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04  8:31 Zelphir Kaltstahl [this message]
2021-05-04 10:15 ` srfi-64 tests passing when they should not Jérémy Korwin-Zmijowski
2021-05-04 11:36   ` Zelphir Kaltstahl
2021-05-05  6:39 ` Taylan Kammer
2021-05-05 13:47   ` Luis Felipe
2021-05-06 11:16     ` Taylan Kammer
2021-05-06 15:33       ` Luis Felipe

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=40a496bb-c005-3c6f-2bf2-7025f3a234bb@posteo.de \
    --to=zelphirkaltstahl@posteo.de \
    --cc=guile-user@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).