On Apr 29, 2011, at 8:30 PM, Sean Bowman wrote:

> Is there any way to test code that uses clojure.contrib.condition to
> raise meaningful error messages?  I've been struggling to write some
> sort of assert-expr, based on thrown-with-condition?, to check for
> these errors, but it's obviously way beyond my macro foo at this
> point.


Midje (https://github.com/marick/Midje) lets you describe 
exceptions-to-be-raised like this:

(fact 
  (/ 1 0) => (throws ArithmeticException))

You can also describe the exception message:

(facts "about throws"
  ...
  (throw-exception "hi") => (throws Error "hi")
  (throw-exception "hi") => (throws Error #"h."))

You could use what's already built in, since conditions are built on top of 
exceptions. Alternately, you could write condition-specific "checkers" 
specialized to clojure.contrib.condition. I could help you with that.

-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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