Hi Frantisek,

I think I understand what you're looking for here, but I don't see how
to make it work. If "are" could be applied to a generated list, then
it would have to evaluate its arguments, which is a pretty fishy thing
for a macro to do. (But possible -- check out clojure.contrib.apply-
macro). Here's how I would write this sequence of assertions:

(deftest zeros-are-equal
  (doall (map (fn [[a b]] (is (= a b)))
              (combinations [0 0.0 0M] 2))))

To answer your other question, if you want a message on each
assertion, just use "is". That's why I've never been crazy about
"are", I feel like it encourages too much succinctness. You also lose
accurate line numbers in error reports.

But if you want, you can use "do-template" in
clojure.contrib.template, which is how "are" is implemented.

(deftest my-test
  (do-template (is (= _1 _2) _3)
    4 (+ 2 2) "simple arithmetic"
    5 (+ 2 2) "bad arithmetic"))

-Stuart Sierra



On Jan 28, 5:29 pm, Frantisek Sodomka <fsodo...@gmail.com> wrote:
> Oops, error. Sequence passed to 'are' cannot be evaluated => use
> quoted list '( or quoted vector '[  ...
>
> (are (= _1 _2)
>   '(3 (+ 1 2)
>     0 (+ -1 1)))
>
> Hm... Since 'are' is basically creating bunch of 'is' tests, I wonder
> how to also add a description message for each test. Thinking along
> the lines:
>
> (are (= _1 _2)
>   '(3 (+ 1 2) "should be 3"
>     0 (+ -1 1) "-x + x = 0"))
>
> (are (is (= _1 _2) _3)
>   '(3 (+ 1 2) "should be 3"
>     0 (+ -1 1) "-x + x = 0"))
>
> (do-parse (is (= _1 _2) _3)
>   '(3 (+ 1 2) "should be 3"
>     0 (+ -1 1) "-x + x = 0"))
>
> Frantisek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to