line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::BlockBase; |
2
|
50
|
|
|
50
|
|
388
|
use strict; |
|
50
|
|
|
|
|
97
|
|
|
50
|
|
|
|
|
1349
|
|
3
|
50
|
|
|
50
|
|
252
|
use warnings; |
|
50
|
|
|
|
|
161
|
|
|
50
|
|
|
|
|
2103
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
50
|
|
|
50
|
|
271
|
use Test2::Util::HashBase qw/code frame _info _lines/; |
|
50
|
|
|
|
|
96
|
|
|
50
|
|
|
|
|
370
|
|
8
|
50
|
|
|
50
|
|
13227
|
use Test2::Util::Sub qw/sub_info/; |
|
50
|
|
|
|
|
118
|
|
|
50
|
|
|
|
|
2683
|
|
9
|
50
|
|
|
50
|
|
298
|
use List::Util qw/min max/; |
|
50
|
|
|
|
|
160
|
|
|
50
|
|
|
|
|
3349
|
|
10
|
50
|
|
|
50
|
|
399
|
use Carp qw/croak/; |
|
50
|
|
|
|
|
98
|
|
|
50
|
|
|
|
|
2647
|
|
11
|
|
|
|
|
|
|
|
12
|
50
|
|
|
50
|
|
444
|
use Test2::Util::Trace(); |
|
50
|
|
|
|
|
106
|
|
|
50
|
|
|
|
|
9796
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN { |
15
|
50
|
|
|
50
|
|
473
|
local ($@, $!, $SIG{__DIE__}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $set_name = eval { require Sub::Util; Sub::Util->can('set_subname') } |
18
|
50
|
|
33
|
|
|
123
|
|| eval { require Sub::Name; Sub::Name->can('subname') }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
*set_subname = $set_name ? sub { |
21
|
1308
|
|
|
1308
|
|
2237
|
my $self = shift; |
22
|
1308
|
|
|
|
|
2307
|
my ($name) = @_; |
23
|
|
|
|
|
|
|
|
24
|
1308
|
|
|
|
|
9328
|
$set_name->($name, $self->{+CODE}); |
25
|
1308
|
|
|
|
|
5128
|
delete $self->{+_INFO}; |
26
|
|
|
|
|
|
|
|
27
|
1308
|
|
|
|
|
3208
|
return 1; |
28
|
50
|
50
|
|
|
|
30084
|
} : sub { return 0 }; |
|
0
|
|
|
|
|
0
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub init { |
32
|
1308
|
|
|
1308
|
0
|
2488
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
croak "The 'code' attribute is required" |
35
|
1308
|
50
|
|
|
|
2998
|
unless $self->{+CODE}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "The 'frame' attribute is required" |
38
|
1308
|
50
|
|
|
|
2684
|
unless $self->{+FRAME}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->{+_LINES} = delete $self->{lines} |
41
|
1308
|
50
|
|
|
|
3564
|
if $self->{lines}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
0
|
0
|
sub file { shift->info->{file} } |
45
|
203
|
|
|
203
|
0
|
377
|
sub lines { shift->info->{lines} } |
46
|
1308
|
|
|
1308
|
0
|
7368
|
sub package { shift->info->{package} } |
47
|
351
|
|
|
351
|
0
|
637
|
sub subname { shift->info->{name} } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub info { |
50
|
1862
|
|
|
1862
|
0
|
2795
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
1862
|
100
|
|
|
|
7975
|
unless ($self->{+_INFO}) { |
53
|
1427
|
|
|
|
|
3760
|
my $info = sub_info($self->code); |
54
|
|
|
|
|
|
|
|
55
|
1427
|
|
|
|
|
4710
|
my $frame = $self->frame; |
56
|
1427
|
|
|
|
|
5240
|
my $file = $info->{file}; |
57
|
1427
|
|
|
|
|
2206
|
my $all_lines = $info->{all_lines}; |
58
|
1427
|
|
|
|
|
2198
|
my $pre_lines = $self->{+_LINES}; |
59
|
1427
|
|
50
|
|
|
3540
|
my $lines = $info->{lines} ||= []; |
60
|
|
|
|
|
|
|
|
61
|
1427
|
50
|
33
|
|
|
3658
|
if ($pre_lines && @$pre_lines) { |
62
|
0
|
|
|
|
|
0
|
@$lines = @$pre_lines; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
1427
|
100
|
|
|
|
6837
|
@$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
|
|
|
|
3136
|
$lines->[0]-- if $lines->[0] != $lines->[1]; |
73
|
|
|
|
|
|
|
|
74
|
1427
|
|
|
|
|
3050
|
$self->{+_INFO} = $info; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
1862
|
|
|
|
|
8374
|
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__ |