32 lines
705 B
Common Lisp
32 lines
705 B
Common Lisp
(defun run-unit-test (unit-test)
|
|
(if (funcall unit-test)
|
|
(progn
|
|
(print (cons t unit-test))
|
|
t)
|
|
|
|
(progn
|
|
(print (cons 'f unit-test))
|
|
nil)))
|
|
|
|
(defun run-test-suite (test-suite)
|
|
(if test-suite
|
|
(cons
|
|
(run-unit-test (car test-suite))
|
|
(run-test-suite (cdr test-suite)))))
|
|
|
|
(defun unit (test-suite)
|
|
(eval (cons 'and (run-test-suite test-suite))))
|
|
|
|
(defun assert (comparison expected actual)
|
|
(if (funcall comparison expected actual)
|
|
t
|
|
(progn
|
|
(print (list expected 'is 'not comparison actual))
|
|
nil)))
|
|
|
|
(defun assert= (expected actual)
|
|
(assert '= expected actual))
|
|
|
|
(defun assert-equal (expected actual)
|
|
(assert 'equal expected actual))
|