This teachpack provides four constructs for testing programs:
The first three forms create tests:
You should place them below the relevant function
definitions in the Definitions Window. Eventually you should place
all tests, such as these, at the bottom of the window.
Finally, generate-report
is a function that displays
statistics of running tests:
Place it at the end of the program or run the expression from the
Interactions window after clicking RUN.
Example: Place the following seven lines into the Definitions Window
and click RUN:
(check-expect (+ 1 1) 2)
(check-expect (+ 1 1) 3)
(check-within (+ 1 1) 2.1 .001)
(check-within (+ 1 1) 2.1 .1)
(check-error (+ 1 1) "3")
(check-error (/ 1 0) "/: division by zero")
(generate-report)
Before you do so, try to figure out which of these tests succeed and which
fail. After clicking run, you see a separate frame that records how many
succeeded and failed and detail information about the failures, including
links for highlighting the source.
{(include "foot.tinc")}