line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::BlockBase; |
2
|
49
|
|
|
49
|
|
92002
|
use strict; |
|
49
|
|
|
|
|
50
|
|
|
49
|
|
|
|
|
997
|
|
3
|
49
|
|
|
49
|
|
128
|
use warnings; |
|
49
|
|
|
|
|
40
|
|
|
49
|
|
|
|
|
944
|
|
4
|
|
|
|
|
|
|
|
5
|
49
|
|
|
49
|
|
149
|
use Test2::Util::HashBase qw/code frame _info _lines/; |
|
49
|
|
|
|
|
38
|
|
|
49
|
|
|
|
|
243
|
|
6
|
49
|
|
|
49
|
|
5187
|
use Test2::Util::Sub qw/sub_info/; |
|
49
|
|
|
|
|
50
|
|
|
49
|
|
|
|
|
1919
|
|
7
|
49
|
|
|
49
|
|
149
|
use List::Util qw/min max/; |
|
49
|
|
|
|
|
50
|
|
|
49
|
|
|
|
|
1942
|
|
8
|
49
|
|
|
49
|
|
154
|
use Carp qw/croak/; |
|
49
|
|
|
|
|
46
|
|
|
49
|
|
|
|
|
1425
|
|
9
|
|
|
|
|
|
|
|
10
|
49
|
|
|
49
|
|
243
|
use Test2::Util::Trace(); |
|
49
|
|
|
|
|
44
|
|
|
49
|
|
|
|
|
5864
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
49
|
|
|
49
|
|
580
|
local ($@, $!, $SIG{__DIE__}); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $set_name = eval { require Sub::Util; Sub::Util->can('set_subname') } |
16
|
49
|
|
33
|
|
|
62
|
|| eval { require Sub::Name; Sub::Name->can('subname') }; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
*set_subname = $set_name ? sub { |
19
|
1300
|
|
|
1300
|
|
1103
|
my $self = shift; |
20
|
1300
|
|
|
|
|
1064
|
my ($name) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1300
|
|
|
|
|
5714
|
$set_name->($name, $self->{+CODE}); |
23
|
1300
|
|
|
|
|
1381
|
delete $self->{+_INFO}; |
24
|
|
|
|
|
|
|
|
25
|
1300
|
|
|
|
|
1934
|
return 1; |
26
|
49
|
50
|
|
|
|
17730
|
} : sub { return 0 }; |
|
0
|
|
|
|
|
0
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub init { |
30
|
1300
|
|
|
1300
|
0
|
936
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
croak "The 'code' attribute is required" |
33
|
1300
|
50
|
|
|
|
2013
|
unless $self->{+CODE}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
croak "The 'frame' attribute is required" |
36
|
1300
|
50
|
|
|
|
1807
|
unless $self->{+FRAME}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$self->{+_LINES} = delete $self->{lines} |
39
|
1300
|
50
|
|
|
|
2897
|
if $self->{lines}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
0
|
0
|
sub file { shift->info->{file} } |
43
|
203
|
|
|
203
|
0
|
214
|
sub lines { shift->info->{lines} } |
44
|
1300
|
|
|
1300
|
0
|
1892
|
sub package { shift->info->{package} } |
45
|
351
|
|
|
351
|
0
|
361
|
sub subname { shift->info->{name} } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub info { |
48
|
1854
|
|
|
1854
|
0
|
1356
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
1854
|
100
|
|
|
|
2561
|
unless ($self->{+_INFO}) { |
51
|
1419
|
|
|
|
|
2339
|
my $info = sub_info($self->code); |
52
|
|
|
|
|
|
|
|
53
|
1419
|
|
|
|
|
119704
|
my $frame = $self->frame; |
54
|
1419
|
|
|
|
|
3078
|
my $file = $info->{file}; |
55
|
1419
|
|
|
|
|
1170
|
my $all_lines = $info->{all_lines}; |
56
|
1419
|
|
|
|
|
1086
|
my $pre_lines = $self->{+_LINES}; |
57
|
1419
|
|
50
|
|
|
2317
|
my $lines = $info->{lines} ||= []; |
58
|
|
|
|
|
|
|
|
59
|
1419
|
50
|
33
|
|
|
2475
|
if ($pre_lines && @$pre_lines) { |
60
|
0
|
|
|
|
|
0
|
@$lines = @$pre_lines; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
1419
|
100
|
|
|
|
4855
|
@$lines = ( |
64
|
|
|
|
|
|
|
min(@$all_lines, $frame->[2]), |
65
|
|
|
|
|
|
|
max(@$all_lines, $frame->[2]), |
66
|
|
|
|
|
|
|
) if $frame->[1] eq $file; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Adjust for start |
70
|
1419
|
100
|
|
|
|
2271
|
$lines->[0]-- if $lines->[0] != $lines->[1]; |
71
|
|
|
|
|
|
|
|
72
|
1419
|
|
|
|
|
1853
|
$self->{+_INFO} = $info; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
1854
|
|
|
|
|
5348
|
return $self->{+_INFO}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub trace { |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
return Test2::Util::Trace->new( |
81
|
|
|
|
|
|
|
frame => $self->frame, |
82
|
|
|
|
|
|
|
detail => $self->debug, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub debug { |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
0
|
|
|
|
|
|
my $file = $self->file; |
89
|
0
|
|
|
|
|
|
my $lines = $self->lines; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
my $line_str = @$lines == 1 ? "around line $lines->[0]" : "around lines $lines->[0] -> $lines->[1]"; |
92
|
0
|
|
|
|
|
|
return "at $file $line_str."; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub throw { |
96
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
97
|
0
|
|
|
|
|
|
my ($msg) = @_; |
98
|
0
|
|
|
|
|
|
die "$msg " . $self->debug . "\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |