unit test - part-cw/lambdanative GitHub Wiki
#(unit-test n . x) unit-test runs or adds a unit test depending on the arguments
Parameter | Description |
---|---|
n | Unit test name |
x | Optional: Unit test declaration (description and test) |
Note: When defining a new unit test two arguments needs to be specified:
a) A short unit-test description, and b) an anonymous function returning #t
when successfully passing the test.
Example
Example 1: Define a unit test for "Matrix value lookup"
(unit-test "listlist-ref" "Matrix value lookup"
(lambda () (and
(equal? (listlist-ref '((4 7) (2 6)) 0 0) 4)
(equal? (listlist-ref '((4 7) (2 6)) 1 1) 6)
(equal? (listlist-ref '((1 2 3)) 0 1) 2)
(equal? (listlist-ref '((1 2 3) (4 5 6) (7 8 9)) 0 2) 3)
(equal? (listlist-ref '((1 2 3) (4 5 6) (7 8 9)) 2 0) 7)
)))
Example 2: Run a specific unit test for "Matrix value lookup" in a REPL
> (unit-test "listlist-ref")
#t