Piers Cawley ([EMAIL PROTECTED]) wrote:
> Adam Spiers <[EMAIL PROTECTED]> writes:

[how to fix T::U::Assertion::CodeRef breakage]

> >   - Change T::U::Assertion::CodeRef::do_assertion to rethrow die()
> >     exceptions as Test::Unit::Failures.  Almost ideal, except for the
> >     serious flaw that syntax errors in the coderef turn up as
> >     failures.
> >
> >   - Change the semantics of T::U::Assertion::CodeRefs so that on
> >     failure they return($failure_msg) rather than die($failure_msg),
> >     and on success they return zero (a la shell)?  That would be very
> >     easy to implement, although confusing in that it's the exact
> >     opposite of Perl's notions of true/false.
> >
> >   - Change the semantics of T::U::Assertion::CodeRefs so that on
> >     failure they throw a Test::Unit::Failure rather than a die().  In
> >     that case, it would be better to drop the current requirement that
> >     a coderef has to return true to indicate success, since it would
> >     no longer be necessary.
> >
> > The third option is my preference.
> 
> Me too. And I can't for the life of me remember *why* I did it any
> different.

Done.  This means the new way to do coderef assertions is

   $self->assert(sub {
                     $_[0] == $_[1]
                       or $self->fail("Expected $_[0], got $_[1]");
                 }, 1, 2);

I've also added two new assertions: assert_multi() and assert_raises().
See the CVS docs for more info.

_______________________________________________
Perlunit-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/perlunit-devel

Reply via email to