X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcheck.lisp;h=5244704f9d3643c8107c218b728db8ec31e62dcf;hb=916f77e439bc09067ef611ab11c9f3630b80b4f5;hp=06c9bba8b63dac0a8aeca35c8f31babc5453673b;hpb=4fec31c7fee75162da986168c8578017c56c197d;p=fiveam.git diff --git a/src/check.lisp b/src/check.lisp index 06c9bba..5244704 100644 --- a/src/check.lisp +++ b/src/check.lisp @@ -165,6 +165,18 @@ Wrapping the TEST form in a NOT simply preducse a negated reason string." (format *test-dribble* "s") (add-result 'test-skipped :reason (format nil ,@reason)))) +(defmacro is-every (predicate &body clauses) + "The input is either a list of lists, or a list of pairs. Generates (is (,predicate ,expr ,value)) + for each pair of elements or (is (,predicate ,expr ,value) ,@reason) for each list." + `(progn + ,@(if (every #'consp clauses) + (loop for (expected actual &rest reason) in clauses + collect `(is (,predicate ,expected ,actual) ,@reason)) + (progn + (assert (evenp (list-length clauses))) + (loop for (expr value) on clauses by #'cddr + collect `(is (,predicate ,expr ,value))))))) + (defmacro is-true (condition &rest reason-args) "Like IS this check generates a pass if CONDITION returns true and a failure if CONDITION returns false. Unlike IS this check @@ -207,13 +219,13 @@ not evaluated." :test-expr ',condition) (return-from ,block-name t)))) (block nil - ,@body - (process-failure - :reason ,(if reason-control - `(format nil ,reason-control ,@reason-args) - `(format nil "Failed to signal a ~S" ',condition)) - :test-expr ',condition) - (return-from ,block-name nil))))))) + ,@body)) + (process-failure + :reason ,(if reason-control + `(format nil ,reason-control ,@reason-args) + `(format nil "Failed to signal a ~S" ',condition)) + :test-expr ',condition) + (return-from ,block-name nil))))) (defmacro finishes (&body body) "Generates a pass if BODY executes to normal completion. In