unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* srfi-64 tests passing when they should not
@ 2021-05-04  8:31 Zelphir Kaltstahl
  2021-05-04 10:15 ` Jérémy Korwin-Zmijowski
  2021-05-05  6:39 ` Taylan Kammer
  0 siblings, 2 replies; 7+ messages in thread
From: Zelphir Kaltstahl @ 2021-05-04  8:31 UTC (permalink / raw)
  To: Guile User

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




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

end of thread, other threads:[~2021-05-06 15:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04  8:31 srfi-64 tests passing when they should not Zelphir Kaltstahl
2021-05-04 10:15 ` 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

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