On 11/08/2011 12:44 PM, AndyK wrote:
> I finally had a chance to try this out and it fails with
>
> error: java.lang.ClassCastException: java.lang.String cannot be cast
> to clojure.lang.IObj
> Compilation failed.
I think I fat-fingered my deftest-form definition:
I originally wrote:
(defn testdef-form [n [expected actual]]
`(deftest ~(str "testfromline" n)
(is (= ~expected ~actual))))
But it should probably be:
(defn testdef-form [n [expected actual]]
`(deftest ~(symbol (str "testfromline" n))
(is (= ~expected ~actual))))
The original, wrong, function would have produced something like this:
(deftest "testfromline27"
(is (= 5 2)))
Which is probably what's giving you the error message you're seeing.
That string should be a symbol:
(deftest testfromline27
(is (= 5 2)))
> When I substituted in something like this...
>
> (defn prn-form [n scenario]
> `(prn ~(str "foo" n) (prn ~(str n " :: " scenario))))
>
> the file did compile.
I'd have to see the rest of your code to comment on what's going on here.
> Is the fact that deftest is also a macro going to cause a problem with
> the original idea?
Macros certainly have composability issues, but its certainly safe to
write a macro that produces some other macro form. In fact, lots of
clojure.core macros use this to great effect (affect?), see ->, cond,
or, and .. to name a few.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en