Test-Fatal
view release on metacpan or search on metacpan
examples/exception_like.t view on Meta::CPAN
123456789101112131415161718use
strict;
use
Test::More;
use
Test::Fatal;
sub
exception_like(&$;$)
{
my
(
$code
,
$pattern
,
$name
) =
@_
;
like(
&exception
(
$code
),
$pattern
,
$name
);
}
exception_like(
sub
{ confess
'blah blah'
},
qr/foo/
,
'foo seems to appear in the exception'
);
# the test only passes when we invert it
unlike(
( exception { confess
'blah blah'
} ||
''
),
( run in 0.250 second using v1.01-cache-2.11-cpan-94b05bcf43c )