例外をテストするならTest::Fatalが書きやすい

use strict;
use Test::More 0.98;

like 'a', qr/a/, q{ like };
eval {die 'a'};
like  $@, qr/a/, q{ like eval };

done_testing;
use strict;
use Test::More 0.98;
use Test::Exception;

like           'a' , qr/a/, q{ like };
throws_ok {die 'a'}  qr/a/, q{ throws_ok };

done_testing;
use strict;
use Test::More 0.98;
use Test::Fatal;

like                'a' , qr/a/, q{ like };
like exception {die 'a'}, qr/a/, q{ like exception };

done_testing;
is exception {'a'}, undef, q{ live };

Comments

comments powered by Disqus