Cute little thing: http://sourceforge.net/projects/lispsnippets/files/tester.lisp
Got the idea from the book — V. A. Potapenko, “Lisp From All Sides” (in Russian). I just added keywords, their default values, and removed
cond (it’s not really needed here).
It takes some
input, applies a
test-function to it, and compares the result with the
eq-p as a comparison operator.
By default it checks that 2 + 2 is 4. You can specify
For example, to check that 2 – 2 – 1 is approximately (with the tolerance 0.5) equal to -1.2, type:
(tester :input '(2 2 1) :output '-1.2 :test-function (lambda (&rest x) (apply #'- x)) :eq-p (lambda (x y) (< (abs (- x y)) 0.5)))