transcendental-lisp/lisp/unit/unit-test.lisp

31 lines
692 B
Common Lisp

(defun run-unit-test (unit-test)
(if (call unit-test)
(begin
(print (cons t unit-test))
t)
(begin
(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)
(apply 'and (run-test-suite test-suite)))
(defun assert (comparison expected actual)
(if (call comparison expected actual)
t
(begin
(print (list expected 'is 'not comparison actual))
nil)))
(defun assert= (expected actual)
(assert '= expected actual))
(defun assert-equal (expected actual)
(assert 'equal expected actual))