Test-Fatal
view release on metacpan or search on metacpan
examples/exception_like.t view on Meta::CPAN
use strict;
use warnings FATAL => 'all';
use Test::More;
use Test::Fatal;
use Carp 'confess';
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.248 second using v1.01-cache-2.11-cpan-94b05bcf43c )