Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.50 KB | None | 0 0
  1. (defun report-result (test test-name)
  2.   (format t "~:[Fail~;Pass~] ... ~A~%" test test-name)
  3.   test)
  4.  
  5. (defmacro combine-results (&body forms)
  6.   (with-gensyms (result)
  7.     `(let ((,result t))
  8.        ,@(loop for f in forms collect `(unless ,f (setf ,result nil)))
  9.        ,result)))
  10.  
  11. (defmacro check (&body forms)
  12.   `(combine-results
  13.      ,@(loop for f in forms collect `(report-result ,f ',f))))
  14.  
  15. (defun test+- ()
  16.     (check (= (+ 1 2 3) 6)
  17.            (= (+ 2 3 4) 9)
  18.            (= (- 2 1) 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement