Here's a first pass at an addition to test_is, the assert-raises macro. It asserts that the given expression throws an exception of the specified type.
There are two things I don't like about this implementation: the name doesn't quite go with the test_is theme, and the (is :a :a) at the bottom. The problem I ran into was that the counters are all private, and it seems like this is more convenient as a macro than using lambda / apply. I figure this is a good starting point for discussion though. +++ src/clojure/contrib/test_is/test_is.clj (working copy) +(defmacro assert-raises + "asserts that the form raises the given expression" + ([ex-class form] + `(assert-raises ~ex-class ~form nil)) + ([ex-class form message] + `(try + (let [value# ~form] + (failure (str "expected " ~(pr-str form) " to raise " ~ex-class ", but returned " value#) ~message)) + (catch ~ex-class e# + (is :a :a))))) ; simple is just to bump the assertion count + Thoughts? Allen --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---