From 916f77e439bc09067ef611ab11c9f3630b80b4f5 Mon Sep 17 00:00:00 2001 From: Attila Lendvai Date: Sun, 1 Oct 2006 19:40:56 +0200 Subject: [PATCH] Dropped is-equal and is-string=, added is-every --- src/check.lisp | 34 ++++++++++------------------------ src/packages.lisp | 3 +-- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/check.lisp b/src/check.lisp index e2a4a95..5244704 100644 --- a/src/check.lisp +++ b/src/check.lisp @@ -165,31 +165,17 @@ 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-equal (&rest args) - "Generates (is (equal (multiple-value-list ,expr) (multiple-value-list ,value))) for each pair of elements. -If the value is a (values a b * d *) form then the elements at * are not compared." - (with-unique-names (expr-result) - `(progn - ,@(loop for (expr value) on args by #'cddr - do (assert (and expr value)) - if (and (consp value) - (eq (car value) 'values)) - collect `(let ((,expr-result (multiple-value-list ,expr))) - ,@(loop for cell = (rest (copy-list value)) then (cdr cell) - for i from 0 - while cell - when (eq (car cell) '*) - collect `(setf (elt ,expr-result ,i) nil) - and do (setf (car cell) nil)) - (is (equal ,expr-result (multiple-value-list ,value)))) - else collect `(is (equal ,expr ,value)))))) - -(defmacro is-string= (&rest args) - "Generates (is (string= ,expr ,value)) for each pair of elements." +(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 - ,@(loop for (expr value) on args by #'cddr - do (assert (and expr value)) - collect `(is (string= ,expr ,value))))) + ,@(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 diff --git a/src/packages.lisp b/src/packages.lisp index 34436f3..747b094 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -38,8 +38,7 @@ #:rem-fixture ;; running checks #:is - #:is-equal - #:is-string= + #:is-every #:is-true #:is-false #:signals -- 1.7.10.4