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

35 lines
869 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 operand1 operand2)
(if (call comparison operand1 operand2)
t
(begin
(print '==================================================)
(print (list comparison 'comparison 'failed))
(print operand1)
(print operand2)
(print '--------------------------------------------------)
nil)))
(defun assert= (expected actual)
(assert '= expected actual))
(defun assert-equal (expected actual)
(assert 'equal expected actual))