line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::BlockBase; |
2
|
50
|
|
|
50
|
|
414
|
use strict; |
|
50
|
|
|
|
|
105
|
|
|
50
|
|
|
|
|
1444
|
|
3
|
50
|
|
|
50
|
|
234
|
use warnings; |
|
50
|
|
|
|
|
93
|
|
|
50
|
|
|
|
|
2025
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
6
|
|
|
|
|
|
|
|
7
|
50
|
|
|
50
|
|
291
|
use Test2::Util::HashBase qw/code frame _info _lines/; |
|
50
|
|
|
|
|
208
|
|
|
50
|
|
|
|
|
385
|
|
8
|
50
|
|
|
50
|
|
13345
|
use Test2::Util::Sub qw/sub_info/; |
|
50
|
|
|
|
|
149
|
|
|
50
|
|
|
|
|
2662
|
|
9
|
50
|
|
|
50
|
|
338
|
use List::Util qw/min max/; |
|
50
|
|
|
|
|
178
|
|
|
50
|
|
|
|
|
2784
|
|
10
|
50
|
|
|
50
|
|
548
|
use Carp qw/croak/; |
|
50
|
|
|
|
|
126
|
|
|
50
|
|
|
|
|
2292
|
|
11
|
|
|
|
|
|
|
|
12
|
50
|
|
|
50
|
|
342
|
use Test2::Util::Trace(); |
|
50
|
|
|
|
|
184
|
|
|
50
|
|
|
|
|
9917
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN { |
15
|
50
|
|
|
50
|
|
549
|
local ($@, $!, $SIG{__DIE__}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $set_name = eval { require Sub::Util; Sub::Util->can('set_subname') } |
18
|
50
|
|
33
|
|
|
134
|
|| eval { require Sub::Name; Sub::Name->can('subname') }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
*set_subname = $set_name ? sub { |
21
|
1308
|
|
|
1308
|
|
2029
|
my $self = shift; |
22
|
1308
|
|
|
|
|
2160
|
my ($name) = @_; |
23
|
|
|
|
|
|
|
|
24
|
1308
|
|
|
|
|
8610
|
$set_name->($name, $self->{+CODE}); |
25
|
1308
|
|
|
|
|
4730
|
delete $self->{+_INFO}; |
26
|
|
|
|
|
|
|
|
27
|
1308
|
|
|
|
|
2843
|
return 1; |
28
|
50
|
50
|
|
|
|
30768
|
} : sub { return 0 }; |
|
0
|
|
|
|
|
0
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub init { |
32
|
1308
|
|
|
1308
|
0
|
2048
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
croak "The 'code' attribute is required" |
35
|
1308
|
50
|
|
|
|
2755
|
unless $self->{+CODE}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "The 'frame' attribute is required" |
38
|
1308
|
50
|
|
|
|
2514
|
unless $self->{+FRAME}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->{+_LINES} = delete $self->{lines} |
41
|
1308
|
50
|
|
|
|
3528
|
if $self->{lines}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
0
|
0
|
sub file { shift->info->{file} } |
45
|
203
|
|
|
203
|
0
|
409
|
sub lines { shift->info->{lines} } |
46
|
1308
|
|
|
1308
|
0
|
7102
|
sub package { shift->info->{package} } |
47
|
351
|
|
|
351
|
0
|
776
|
sub subname { shift->info->{name} } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub info { |
50
|
1862
|
|
|
1862
|
0
|
4460
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
1862
|
100
|
|
|
|
6521
|
unless ($self->{+_INFO}) { |
53
|
1427
|
|
|
|
|
5689
|
my $info = sub_info($self->code); |
54
|
|
|
|
|
|
|
|
55
|
1427
|
|
|
|
|
4679
|
my $frame = $self->frame; |
56
|
1427
|
|
|
|
|
4912
|
my $file = $info->{file}; |
57
|
1427
|
|
|
|
|
2133
|
my $all_lines = $info->{all_lines}; |
58
|
1427
|
|
|
|
|
2279
|
my $pre_lines = $self->{+_LINES}; |
59
|
1427
|
|
50
|
|
|
3317
|
my $lines = $info->{lines} ||= []; |
60
|
|
|
|
|
|
|
|
61
|
1427
|
50
|
33
|
|
|
3464
|
if ($pre_lines && @$pre_lines) { |
62
|
0
|
|
|
|
|
0
|
@$lines = @$pre_lines; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
1427
|
100
|
|
|
|
6559
|
@$lines = ( |
66
|
|
|
|
|
|
|
min(@$all_lines, $frame->[2]), |
67
|
|
|
|
|
|
|
max(@$all_lines, $frame->[2]), |
68
|
|
|
|
|
|
|
) if $frame->[1] eq $file; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Adjust for start |
72
|
1427
|
100
|
|
|
|
3184
|
$lines->[0]-- if $lines->[0] != $lines->[1]; |
73
|
|
|
|
|
|
|
|
74
|
1427
|
|
|
|
|
3009
|
$self->{+_INFO} = $info; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
1862
|
|
|
|
|
8323
|
return $self->{+_INFO}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub trace { |
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my ($hub, %params) = @_; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
croak "'hub' is required" |
86
|
|
|
|
|
|
|
unless $hub; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return Test2::Util::Trace->new( |
89
|
|
|
|
|
|
|
frame => $self->frame, |
90
|
|
|
|
|
|
|
detail => $self->debug, |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
buffered => $hub->buffered, |
93
|
|
|
|
|
|
|
nested => $hub->nested, |
94
|
|
|
|
|
|
|
hid => $hub->hid, |
95
|
|
|
|
|
|
|
huuid => $hub->uuid, |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
%params, |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub debug { |
102
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
103
|
0
|
|
|
|
|
|
my $file = $self->file; |
104
|
0
|
|
|
|
|
|
my $lines = $self->lines; |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
my $line_str = @$lines == 1 ? "around line $lines->[0]" : "around lines $lines->[0] -> $lines->[1]"; |
107
|
0
|
|
|
|
|
|
return "at $file $line_str."; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub throw { |
111
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
112
|
0
|
|
|
|
|
|
my ($msg) = @_; |
113
|
0
|
|
|
|
|
|
die "$msg " . $self->debug . "\n"; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |