Unit Testing

Defines a set of functions to write test scripts.

N.B.  (mosh test) used to use (srfi :64 testing) as backend, but it is rewritten for performance reason.

Example

(import (rnrs)
        (mosh test)
  (test-false (number? 'a))
  (test-results))
Summary
Unit TestingDefines a set of functions to write test scripts.
(mosh test)Unit Testing library
Functions
failAlways fail.
test-trueRun the test and check the result is not #f.
test-falseRun the test and check the result is #f.
test-eqThis is equivalent to
test-eqvThis is equivalent to
test-equalThis is equivalent to
test-write-equalCheck (write expr) is equal to expected.
test-errorEvaluating test-expr is expected to signal an error.The kind of error is indicated by error-type.
test-nullRun the test and check the result is null.
test-resultsShow the test results.
good-enough?for floating point number comparison.

(mosh test)

Unit Testing library

Summary
Functions
failAlways fail.
test-trueRun the test and check the result is not #f.
test-falseRun the test and check the result is #f.
test-eqThis is equivalent to
test-eqvThis is equivalent to
test-equalThis is equivalent to
test-write-equalCheck (write expr) is equal to expected.
test-errorEvaluating test-expr is expected to signal an error.The kind of error is indicated by error-type.
test-nullRun the test and check the result is null.
test-resultsShow the test results.
good-enough?for floating point number comparison.

Functions

fail

Always fail.

Prototype

(fail message)

Parameters

messagefailure message

Returns

unspecified.

test-true

Run the test and check the result is not #f.

Prototype

(test-true expression)

Parameters

expressionexpression to evaluate.

Returns

unspecified.

test-false

Run the test and check the result is #f.

Prototype

(test-false expression)

Parameters

expressionexpression to evaluate.

Returns

unspecified.

test-eq

This is equivalent to

(test-assert (eq? expected test-expr))

Run the test and check the result is #f.

Prototype

(test-eq expected test-expr)

Parameters

expectedexpected values
test-exprtest-expr to evaluate.

Returns

unspecified.

test-eqv

This is equivalent to

(test-assert (eqv? expected test-expr))

Run the test and check the result is #f.

Prototype

(test-eqv expected test-expr)

Parameters

expectedexpected values
test-exprtest-expr to evaluate.

Returns

unspecified.

test-equal

This is equivalent to

(test-assert (equal? expected test-expr))

Run the test and check the result is #f.

Prototype

(test-equal expected test-expr)

Parameters

expectedexpected values
test-exprtest-expr to evaluate.

Returns

unspecified.

test-write-equal

Check (write expr) is equal to expected.

Prototype

(test-write-equal expected test-expr)

Parameters

expectedexpected values
test-exprtest-expr to evaluate.

Returns

unspecified.

test-error

Evaluating test-expr is expected to signal an error.The kind of error is indicated by error-type.

If the error-type is left out, or it is #t, it means “some kind of unspecified error should be signaled”.

Prototype

(test-error error-type test-expr)

Parameters

test-nametest name.
error-typeerror-type pred
test-exprtest-expr to evaluate.

Returns

unspecified.

test-null

Run the test and check the result is null.

Prototype

(test-null expression)

Parameters

expressionexpression to evaluate.

Returns

unspecified.

test-results

Show the test results.

Prototype

(test-results)

Returns

unspecified.

good-enough?

for floating point number comparison.

Prototype

(good-enough? lhs rhs)

Returns

#t or #f.

Close