Smart-Args

 view release on metacpan or  search on metacpan

t/Util.pm  view on Meta::CPAN

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
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 )