On Tue, Apr 09, 2002 at 10:05:49PM +0100, Adrian Howard wrote:
> Hi all,
> 
> I've been refactoring a bunch of old tests with Test::More and some
> convenience routines for testing exceptions dropped out (along with some
> class base testing and mock object modules which still need cleaning up into
> something sane.)
> 
>     dies_ok BLOCK TEST_NAME
>         Tests to see that BLOCK exits by dying, rather than by exiting
>         normally. For example:
>     
>             dies_ok { div(1, 0) } 'divide by zero detected';

You probably want to guarantee that $@ will be how it died so you can do:

    dies_ok { div(1,0) } 'div by zero';
    like( $@, qr/^Illegal division by zero/ );

Even though you can use throws_ok(), the dies_ok() + $@ combo is more
flexible more processing than just a regex needs to be done on $@.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Death follows me like a wee followey thing.
        -- Quakeman

Reply via email to