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

32 lines
699 B
Common Lisp
Raw Normal View History

(defun run-unit-test (unit-test)
2017-03-07 16:27:11 -05:00
(if (call unit-test)
(progn
(print (cons t unit-test))
2017-03-06 11:00:18 -05:00
t)
(progn
2017-03-03 15:06:49 -05:00
(print (cons 'f unit-test))
2017-03-06 11:00:18 -05:00
nil)))
(defun run-test-suite (test-suite)
(if test-suite
(cons
(run-unit-test (car test-suite))
2017-03-06 11:00:18 -05:00
(run-test-suite (cdr test-suite)))))
(defun unit (test-suite)
2017-03-06 11:00:18 -05:00
(eval (cons 'and (run-test-suite test-suite))))
2017-02-15 09:29:57 -05:00
(defun assert (comparison expected actual)
2017-03-07 16:27:11 -05:00
(if (call comparison expected actual)
t
(progn
(print (list expected 'is 'not comparison actual))
2017-03-06 11:00:18 -05:00
nil)))
(defun assert= (expected actual)
2017-03-06 11:00:18 -05:00
(assert '= expected actual))
(defun assert-equal (expected actual)
2017-03-06 11:00:18 -05:00
(assert 'equal expected actual))