32 lines
699 B
Common Lisp
32 lines
699 B
Common Lisp
(defun run-unit-test (unit-test)
|
|
(if (call 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 (call 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))
|