PCL: unit test frame work, stuck.
Posted: Tue Feb 02, 2010 4:30 pm
I'm going through Practical common lisp right now I'm stuck on the unit testing frame work. I've been checking and rechecking the syntax, closed the IDE and even copied the examples from the website to compare on the screen and I'm not seeing anything wrong.
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]
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)))