As a side note I don't get how the macros combine-results and check interact with each other so an explanation would be nice. Does the loop run twice? because that seems like it would be bad form.
running (test-+) gives me an error. EVAL: variable RESULT has no value
[Condition of type SYSTEM::SIMPLE-UNBOUND-VARIABLE]
Code: Select all
(defun report-result (result form)
(format t "~:[FAIL~;passs~] ... ~a~%" result form))
(defmacro check (&body forms)
`(combine-results
,@(loop for f in forms collect `(report-result ,f ',f))))
(defmacro combine-results (&body forms)
(with-gensyms (result)
`(let ((,result t))
,@(loop for f in forms collect `(unless ,f (setf ,result nil)))
,result)))
(defun test-+ ()
(check (= (+ 1 2) 3)
(= (+ 1 2) 3)))