The Standard Testing Library

To use the test library

(import :std/test)

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.

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.

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 of expr with the expected value.
  • the second form uses a custom equality predicate to compare the result of expr with value.
  • the third form applies the predicate predicate.
  • the fourth form compares the result with value using the equality function equality-function.

checkf

(checkf equality-predicate expr value)

Evaluates expr and asserts that the the value is as expected, using the equality-predicate.

check-eq?

(check-eq? expr value)

Equivalent to (checkf eq? expr value).

check-not-eq?

(check-not-eq? expr value)

Equivalent to (checkf (? not eq?) expr value).

check-eqv?

(check-eqv? expr value)

Equivalent to (checkf eqv? expr value).

check-not-eqv?

(check-not-eqv? expr value)

Equivalent to (checkf (? not eqv?) expr value).

check-equal?

(check-equal? expr value)

Equivalent to (checkf equal? expr value).

check-not-equal?

(check-not-equal? expr value)

Equivalent to (checkf (? not equal?) expr value).

check-output

(check-output expr output)

Evaluates expr capturing its output and asserts it is equal to the expected output.

check-predicate

(check-predicate expr pred)

Evaluates expr and asserts that its value satisfies the predicate pred.

check-exception

(check-exception expr exn-pred)

Evaluates expr and asserts that it raises an exception that satisfies the predicate exn-pred.