line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Util::Guard; |
2
|
|
|
|
|
|
|
|
3
|
76
|
|
|
76
|
|
625
|
use strict; |
|
76
|
|
|
|
|
395
|
|
|
76
|
|
|
|
|
2563
|
|
4
|
76
|
|
|
76
|
|
434
|
use warnings; |
|
76
|
|
|
|
|
163
|
|
|
76
|
|
|
|
|
2069
|
|
5
|
|
|
|
|
|
|
|
6
|
76
|
|
|
76
|
|
404
|
use Carp qw(confess); |
|
76
|
|
|
|
|
174
|
|
|
76
|
|
|
|
|
20357
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
58
|
50
|
|
58
|
0
|
871
|
confess "Can't create a Test2::Util::Guard in void context" unless (defined wantarray); |
12
|
|
|
|
|
|
|
|
13
|
58
|
|
|
|
|
475
|
my $class = shift; |
14
|
58
|
|
50
|
|
|
1348
|
my $handler = shift() || die 'Test2::Util::Guard::new: no handler supplied'; |
15
|
58
|
|
50
|
|
|
863
|
my $ref = ref $handler || ''; |
16
|
|
|
|
|
|
|
|
17
|
58
|
50
|
|
|
|
983
|
die "Test2::Util::new: invalid handler - expected CODE ref, got: '$ref'" |
18
|
|
|
|
|
|
|
unless ref($handler) eq 'CODE'; |
19
|
|
|
|
|
|
|
|
20
|
58
|
|
33
|
|
|
3187
|
bless [ 0, $handler ], ref $class || $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub dismiss { |
24
|
51
|
|
|
51
|
0
|
460
|
my $self = shift; |
25
|
51
|
50
|
|
|
|
1018
|
my $dismiss = @_ ? shift : 1; |
26
|
|
|
|
|
|
|
|
27
|
51
|
|
|
|
|
619
|
$self->[0] = $dismiss; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub DESTROY { |
31
|
52
|
|
|
52
|
|
8881
|
my $self = shift; |
32
|
52
|
|
|
|
|
309
|
my ($dismiss, $handler) = @$self; |
33
|
|
|
|
|
|
|
|
34
|
52
|
100
|
|
|
|
21033
|
$handler->() unless ($dismiss); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |