4.25 The Standard Testing Library
To use the test library
(import :std/test)
4.25.1 test-suite
(test-suite description case ...) -> test-suite
description := string; description of the test suite
case := test-case
Creates a test suite with one ore more test cases.
4.25.2 test-case
(test-case description body ...) -> test-case
description := string; description of the test case
body := code, as in the body of a lambda
Creates a new test case, with the body executed in a thunk.
4.25.3 check
(check expr => value)
(check expr => value :: equality-function)
(check expr ? predicate)
(check equality-function expr value)
Evaluates an expr and asserts that its value is the expected one:
-
the first form uses
equal?to compare the result ofexprwith the expected value. -
the second form uses a custom equality predicate to compare the result of
exprwithvalue. -
the third form applies the predicate
predicate. -
the fourth form compares the result with
valueusing the equality functionequality-function.
4.25.4 checkf
(checkf equality-predicate expr value)
Evaluates expr and asserts that the the value is as expected, using the equality-predicate.
4.25.5 check-eq?
(check-eq? expr value)
Equivalent to (checkf eq? expr value).
4.25.6 check-not-eq?
(check-not-eq? expr value)
Equivalent to (checkf (? not eq?) expr value).
4.25.7 check-eqv?
(check-eqv? expr value)
Equivalent to (checkf eqv? expr value).
4.25.8 check-not-eqv?
(check-not-eqv? expr value)
Equivalent to (checkf (? not eqv?) expr value).
4.25.9 check-equal?
(check-equal? expr value)
Equivalent to (checkf equal? expr value).
4.25.10 check-not-equal?
(check-not-equal? expr value)
Equivalent to (checkf (? not equal?) expr value).
4.25.11 check-output
(check-output expr output)
Evaluates expr capturing its output and asserts it is equal to the expected output.
4.25.12 check-predicate
(check-predicate expr pred)
Evaluates expr and asserts that its value satisfies the predicate pred.
4.25.13 check-exception
(check-exception expr exn-pred)
Evaluates expr and asserts that it raises an exception that satisfies the predicate exn-pred.