1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

* lib.scm: Documented the short form for pass-if and expect-fail.

(pass-if, expect-fail): Simplified.
This commit is contained in:
Dirk Herrmann 2003-05-30 10:35:05 +00:00
parent 1e498fbd0f
commit e46083d5c5
2 changed files with 22 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2003-05-30 Dirk Herrmann <D.Herrmann@tu-bs.de>
* lib.scm: Documented the short form for pass-if and expect-fail.
(pass-if, expect-fail): Simplified.
2003-05-30 Kevin Ryde <user42@zip.com.au> 2003-05-30 Kevin Ryde <user42@zip.com.au>
* tests/numbers.test (max, min): Add tests involving NaNs. * tests/numbers.test (max, min): Add tests involving NaNs.

View file

@ -124,6 +124,20 @@
;;;; ;;;;
;;;; In that case, the test name is the list ("simple addition"). ;;;; In that case, the test name is the list ("simple addition").
;;;; ;;;;
;;;; In the case of simple tests the expression that is tested would often
;;;; suffice as a test name by itself. Therefore, the convenience macros
;;;; pass-if and expect-fail provide a shorthand notation that allows to omit
;;;; a test name in such cases.
;;;;
;;;; * (pass-if expression) is a short form for
;;;; (run-test 'expression #t (lambda () expression))
;;;; * (expect-fail expression) is a short form for
;;;; (run-test 'expression #f (lambda () expression))
;;;;
;;;; For example:
;;;;
;;;; (pass-if (= 2 (+ 1 1)))
;;;;
;;;; The WITH-TEST-PREFIX syntax and WITH-TEST-PREFIX* procedure establish ;;;; The WITH-TEST-PREFIX syntax and WITH-TEST-PREFIX* procedure establish
;;;; a prefix for the names of all tests whose results are reported ;;;; a prefix for the names of all tests whose results are reported
;;;; within their dynamic scope. For example: ;;;; within their dynamic scope. For example:
@ -277,9 +291,7 @@
(if (and (null? rest) (pair? name)) (if (and (null? rest) (pair? name))
;; presume this is a simple test, i.e. (pass-if (even? 2)) ;; presume this is a simple test, i.e. (pass-if (even? 2))
;; where the body should also be the name. ;; where the body should also be the name.
`(run-test ,(with-output-to-string (lambda () (display name))) `(run-test ',name #t (lambda () ,name))
#t
(lambda () ,name))
`(run-test ,name #t (lambda () ,@rest)))) `(run-test ,name #t (lambda () ,@rest))))
;;; A short form for tests that are expected to fail, taken from Greg. ;;; A short form for tests that are expected to fail, taken from Greg.
@ -287,9 +299,7 @@
(if (and (null? rest) (pair? name)) (if (and (null? rest) (pair? name))
;; presume this is a simple test, i.e. (expect-fail (even? 2)) ;; presume this is a simple test, i.e. (expect-fail (even? 2))
;; where the body should also be the name. ;; where the body should also be the name.
`(run-test ,(with-output-to-string (lambda () (display name))) `(run-test ',name #f (lambda () ,name))
#f
(lambda () ,name))
`(run-test ,name #f (lambda () ,@rest)))) `(run-test ,name #f (lambda () ,@rest))))
;;; A helper function to implement the macros that test for exceptions. ;;; A helper function to implement the macros that test for exceptions.