Smart-Args
view release on metacpan or search on metacpan
234567891011121314151617181920212223242526272829303132333435use
strict;
use
warnings;
use
utf8;
my
$CLASS
= __PACKAGE__;
our
@EXPORT
=
qw/lives_ok throws_ok lives_and/
;
sub
lives_ok(&;$) {
my
(
$code
,
$description
) =
@_
;
my
$tb
=
$CLASS
->builder;
eval
{
$code
->() };
$tb
->ok(!$@,
$description
||
"lives_ok"
);
}
sub
throws_ok(&$;$) {
my
(
$code
,
$regexp
,
$description
) =
@_
;
my
$tb
=
$CLASS
->builder;
eval
{
$code
->() };
$tb
->like($@,
$regexp
,
$description
||
"throws_ok"
);
}
sub
lives_and(&;$) {
my
(
$code
,
$description
) =
@_
;
$CLASS
->builder->subtest(
$description
||
'lives_and'
,
sub
{
local
$Test::Builder::Level
=
$Test::Builder::Level
+ 1;
eval
{
$code
->();
};
$CLASS
->builder->ok(!$@,
$description
||
'lives_and'
);
});
}
( run in 0.335 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )