Hi Paul,
Thanks, glad you like it.  I hadn't seen your earlier post -- wasn't
following the group for a couple weeks there.  My first inclination is
not to catch any Error subclasses, as Sun says,
http://java.sun.com/javase/6/docs/api/java/lang/Error.html

But, StackOverflowError might be an exception (no pun intended) to the
rule, at least according to this guy:
http://blog.igorminar.com/2008/05/catching-stackoverflowerror-and-bug-in.html

In any case, if you want to assert that a particular form *always*
throws an error, you can use the "throws" macro:

user=> (use 'clojure.contrib.test-is)
nil
user=> (defn foo ([] (foo))
         {:test (fn [] (throws java.lang.StackOverflowError (foo)))})
#'user/foo
user=> (run-tests)
Testing user

Ran 1 tests with 1 assertions.
0 failures, 0 exceptions.
nil
user=> (foo)
java.lang.StackOverflowError (NO_SOURCE_FILE:0)


So I probably won't catch Error, unless there's another scenario in
which it's needed.
-Stuart Sierra



On Nov 17, 6:33 am, "Paul Drummond" <[EMAIL PROTECTED]> wrote:
> Hi Stuart,
>
> Cool additions - I will certainly use them.
>
> Regarding test-is additions, did you ever get a chance to check out the
> patch I submitted a while back?
>
> http://groups.google.com/group/clojure/browse_thread/thread/c509d589e...
>
> It was my first patch so appologies if there are some glaring errors or
> bad-style in there (but it was a very simple addition so I'd hope not!).
>
> I realised just after posting that catching Errors in the general case could
> be viewed as a no-no because the JVM could be in an unstable state after the
> Error (depending on which error was thrown) so the desired outcome would be
> to terminate.  Is that your view?
>
> For my particular scenario, I wanted test-is to support StackOverflowError.
> I was working on a SICP exercise that caused StackOverflowErrors and I
> wanted to have a test that passed when a StackOverflowError occurred, then
> continue processing other tests.  So in my specific case, I felt the patch
> made sense but maybe supporting *all* Errors is going to far?
>
> Hmmm........
>
> Cheers,
> Paul.
>
> --
> Iode Software Ltd, registered in England No. 6299803.
>
> Registered Office Address: 12 Sancroft Drive, Houghton-le-Spring, Tyne &
> Wear, DH5 8NE.
>
> This message is intended only for the use of the person(s) ("the intended
> recipient(s)") to whom it is addressed. It may contain information which is
> privileged and confidential within the meaning of applicable law. If you are
> not the intended recipient, please contact the sender as soon as possible.
> The views expressed in this communication may not necessarily be the views
> held by The Company.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to