You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been working my way through Practical Lisp's examples and have a file with the basic "testing" functions and macros they describe in the book. When loading the file and running the test-arithmetic function, the first line is formatted oddly in the REPL, but subsequent lines are correct. Invoking a single call to the function that produces the output is also formatted oddly, so it looks like it might be an issue with the first item sent to the REPL output?
hello.lisp
(defvar *test-name* nil)
(defun report-result (result form)
(format t "~:[FAIL~;pass~] ... ~a: ~a~%" result *test-name* form)
result)
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(loop for n in names collect `(,n (gensym)))
,@body))
(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)))
(defmacro deftest (name parameters &body body)
`(defun ,name ,parameters
(let ((*test-name* (append *test-name* (list ',name))))
,@body)))
(deftest test-+ ()
(check
(= (+ 1 2) 3)
(= (+ 1 2 3) 6)
(= (+ -1 -3) -5)))
(deftest test-* ()
(check
(= (* 2 2) 4)
(= (* 3 5) 15)))
(deftest test-arithmetic ()
(combine-results
(test-+)
(test-*)))
NB: the build-without-deploy branch has been merged on master. (context: it simply removes the Deploy tool from the build process, as we don't need it anymore to help with foreign dependencies)
I have been working my way through Practical Lisp's examples and have a file with the basic "testing" functions and macros they describe in the book. When loading the file and running the
test-arithmetic
function, the first line is formatted oddly in the REPL, but subsequent lines are correct. Invoking a single call to the function that produces the output is also formatted oddly, so it looks like it might be an issue with the first item sent to the REPL output?hello.lisp
Output:
The text was updated successfully, but these errors were encountered: