2017-03-09 11:19:15 -05:00
|
|
|
(load "../lang/dlambda.lisp")
|
|
|
|
|
|
|
|
(let ((private-static) (public-static))
|
|
|
|
|
|
|
|
(defun unit-tester-assertions ()
|
|
|
|
public-static)
|
|
|
|
|
|
|
|
(setq private-static
|
2017-03-10 15:08:42 -05:00
|
|
|
(dlambda
|
|
|
|
(:assertion-failed (comparison operand1 operand2)
|
|
|
|
(call private-static :print-failure comparison operand1 operand2)
|
|
|
|
nil)
|
|
|
|
|
|
|
|
(:print-failure (comparison operand1 operand2)
|
|
|
|
(print '==================================================)
|
|
|
|
(print (list comparison 'comparison 'failed))
|
|
|
|
(print operand1)
|
|
|
|
(print operand2)
|
|
|
|
(print '--------------------------------------------------))))
|
2017-03-09 11:19:15 -05:00
|
|
|
|
|
|
|
(setq public-static
|
2017-03-10 15:08:42 -05:00
|
|
|
(dlambda
|
|
|
|
(:assert= (expected actual)
|
|
|
|
(call public-static :assert '= expected actual))
|
2017-03-09 11:19:15 -05:00
|
|
|
|
2017-03-10 15:08:42 -05:00
|
|
|
(:assert-equal (expected actual)
|
|
|
|
(call public-static :assert 'equal expected actual))
|
2017-03-09 11:19:15 -05:00
|
|
|
|
2017-03-13 14:43:31 -04:00
|
|
|
(:assert-gensym-equal (expected actual)
|
|
|
|
(call public-static :assert 'gensym-equal expected actual))
|
|
|
|
|
2017-03-10 15:08:42 -05:00
|
|
|
(:assert (comparison operand1 operand2)
|
|
|
|
(if (call comparison operand1 operand2)
|
|
|
|
t
|
|
|
|
(call private-static :assertion-failed comparison operand1 operand2)))))
|
2017-03-09 11:19:15 -05:00
|
|
|
|
|
|
|
(defun unit-tester (suite)
|
|
|
|
(let ((private) (public)
|
|
|
|
(suite suite))
|
|
|
|
|
|
|
|
(setq private
|
2017-03-10 15:08:42 -05:00
|
|
|
(dlambda
|
|
|
|
(:run-suite (suite)
|
|
|
|
(if suite
|
|
|
|
(cons
|
|
|
|
(call private :run-test (car suite))
|
|
|
|
(call private :run-suite (cdr suite)))))
|
|
|
|
|
|
|
|
(:run-test (test)
|
|
|
|
(if (call test)
|
|
|
|
(call private :indicate-success test)
|
|
|
|
(call private :indicate-failure test)))
|
|
|
|
|
|
|
|
(:indicate-success (test)
|
|
|
|
(print (cons t test))
|
|
|
|
t)
|
|
|
|
|
|
|
|
(:indicate-failure (test)
|
|
|
|
(print (cons 'f test))
|
|
|
|
nil)))
|
2017-03-09 11:19:15 -05:00
|
|
|
|
|
|
|
(setq public
|
2017-03-10 15:08:42 -05:00
|
|
|
(dlambda
|
|
|
|
(:run ()
|
2017-03-13 14:43:31 -04:00
|
|
|
(apply 'and (call private :run-suite suite)))
|
|
|
|
|
|
|
|
(t ()
|
|
|
|
(call public :run)))))))
|