Femtounit is a unit test framework for Medley Interlisp based on the PCL unit test framework by Peter Seibel described in Chapter 9 of his book Practical Common Lisp.
Download the file FEMTOUNIT
from the project repo, copy it to a file system location your Medley Interlisp installation has access to, and optionally compile the source by evaluating the following expression from the Lisp executive:
(TCOMPL 'FEMTOUNIT)
Provide these answers to the questions the compiler asks:
- listing? no
- redefine? yes
- save exprs? no
Finally, to load the framework evaluate:
(FILESLOAD FEMTOUNIT)
Suppose you want to test this function that returns the square of its argument:
(DEFINEQ (SQUARE (X) (TIMES X X)))
Assuming Femtounit is loaded, you may define a test function like this by evaluating:
(DEFTEST TEST.SQUARE ()
(CHECK.EXPECT (EQP (SQUARE 1) 1)
(EQP (SQUARE 2) 4)
(EQP (SQUARE 3) 9)
(EQP (SQUARE 4) 16)))
To run the tests call the test function by evaluating:
(TEST.SQUARE)
which will print a dot character for every passed test:
....
You can use the following Lisp forms to create and run unit tests and test suites.
(DEFTEST NAME PARAMETERS BODY)
(macro): Define a test function called NAME
with a list of PARAMETERS
and a sequence of forms as the BODY
. The test function has a syntax similar to defun
in Common Lisp.
A test function can call other test functions or use CHECK.EXPECT
to run individual test cases.
(CHECK.EXPECT FORMS)
(macro): Run each expression in the sequence of FORMS
as a test case.
(COMBINE.RESULTS FORMS)
(macro): Combine the results as booleans of evaluating the sequence of FORMS
in order. Similar to AND
but all the forms are evaluated.
See the list of releases for notes on the changes in each version.
Femtounit is developed by Paolo Amoroso.
This code is distributed under the MIT license, see the LICENSE
file.