TOC of the series
The next transformation affects tests. You can stick with
check-engine/racket-tests, but it is much more common to rely on the functionality of
rackunit has its own set of functions. For our tests so far we need
check-false, for tests whose expected result is
check-equal? for the rest of the cases.
Tests can go in its own file, at the end of the file, or, as you are accustomed to, intermixed with function definitions. If you, as many Racket programmers, prefer the latter behavior, you need to put tests in a submodule within the file, which is a module itself. To do so place your tests inside
(module+ test ...) one per unit tested. It is common to introduce this form in the initial require section, too, with
(require rackunit) and whatever will be shared by other test submodules below.
Another transformation that we carry out now is to be more specific about the functions per loaded module we are going to use.
require supports this, a functionality only available in Racket. The benefits are twofold: you require only what you need, which is more efficient, and you always know exactly where your functions come from.
For more information about
only-in, see Imports: require [The Racket Guide].
Next article in the series: Racket: