blib/lib/Test2/Workflow/BlockBase.pm

filter: Statementstmt 75.7% 53 / 70 Branchbran 55.0% 11 / 20 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 73.6% 14 / 19 Podpod 0.0% 0 / 9 totaltotal 61.8% 81 / 131 CC 14 SCAR 13.1
CC
14
Cov
68%
info
7.3
trace
6.0
debug
6.0
CRAP 3.7
« blib/lib/ok.pm ↑ Summary blib/lib/Test2/API/InterceptResult/Squasher.pm »
1 package Test2::Workflow::BlockBase;
2 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 41 our $VERSION = '1.302226';
6  
7 41 ▶use Test2::Util::HashBase qw/code frame _info _lines/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 41 ▶use Test2::Util::Sub qw/sub_info/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 41 ▶use List::Util qw/min max/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 41 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 41 ▶use Test2::Util::Trace();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 41 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=12.0
15 41 local ($@, $!, $SIG{__DIE__});
16  
17 41 my $set_name = eval { require Sub::Util; Sub::Util->can('set_subname') }
18 0 ▶ || eval { require Sub::Name; Sub::Name->can('subname') };
Condition33%1/3
eval { do { require Sub::Util; 'Sub::Util'->can('set_subname') } } || eval { do { require Sub::Name; 'Sub::Name'->can('subname') } }
l!l&&r!l&&!r
4100
MC/DC0%0/2
eval { do { require Sub::Util; 'Sub::Util'->can('set_subname') } } || eval { do { require Sub::Name; 'Sub::Name'->can('subname') } }
eval { do { require Sub::Util; 'Sub::Util'->can('set_subname') } } eval { do { require Sub::Name; 'Sub::Name'->can('subname') } }
Truth table33%1/3
A || B
A= eval { do { require Sub::Util; 'Sub::Util'->can('set_subname') } }B= eval { do { require Sub::Name; 'Sub::Name'->can('subname') } }
ABresult
1X1
011
000
19  
20 712 ▶ *set_subname = $set_name ? sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 712 my $self = shift;
22 712 my ($name) = @_;
23  
24 712 $set_name->($name, $self->{+CODE});
25 712 delete $self->{+_INFO};
26  
27 712 return 1;
28 0 ▶ } : sub { return 0 };
Subroutine __ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
$set_name ? : 41 0 41
29 }
30  
31 712 ▶sub init {
Subroutine init: called CC=4 SCAR=14.9
Pod undocumented
32 712 my $self = shift;
33  
34 croak "The 'code' attribute is required"
35 712 ▶ unless $self->{+CODE};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"code"} 0 712 712
36  
37 croak "The 'frame' attribute is required"
38 712 ▶ unless $self->{+FRAME};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"frame"} 0 712 712
39  
40 $self->{+_LINES} = delete $self->{lines}
41 712 ▶ if $self->{lines};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"lines"} 0 712 712
42 }
43  
44 0 ▶sub file { shift->info->{file} }
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
45 203 ▶sub lines { shift->info->{lines} }
Subroutine lines: called CC=1 SCAR=0.0
Pod undocumented
46 712 ▶sub package { shift->info->{package} }
Subroutine package: called CC=1 SCAR=0.0
Pod undocumented
47 351 ▶sub subname { shift->info->{name} }
Subroutine subname: called CC=1 SCAR=0.0
Pod undocumented
48  
49 1266 ▶sub info {
Subroutine info: called CC=7 SCAR=19.9
Pod undocumented
50 1266 my $self = shift;
51  
52 1266 ▶ unless ($self->{+_INFO}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_info"}) 831 435 1266
53 831 my $info = sub_info($self->code);
54  
55 831 my $frame = $self->frame;
56 831 my $file = $info->{file};
57 831 my $all_lines = $info->{all_lines};
58 831 my $pre_lines = $self->{+_LINES};
59 831 ▶ my $lines = $info->{lines} ||= [];
Condition50%1/2
$info->{"lines"} ||= []
l!l
8310
MC/DC0%0/1
$info->{"lines"} ||= []
$info->{"lines"}
Truth table50%1/2
A
A= $info->{"lines"}
Aresult
11
00
60  
61 831 ▶ if ($pre_lines && @$pre_lines) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre_lines and @$pre_lines) { } 0 831 831
Condition33%1/3
$pre_lines and @$pre_lines
!ll&&!rl&&r
83100
MC/DC0%0/2
$pre_lines and @$pre_lines
$pre_lines @$pre_lines
Truth table33%1/3
A and B
A= $pre_linesB= @$pre_lines
ABresult
0X0
100
111
62 0 @$lines = @$pre_lines;
63 }
64 else {
65 831 ▶ @$lines = (
Branch: 1 branch
BranchTrueFalseTotal
if $frame->[1] eq $file 765 66 831
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 831 ▶ $lines->[0]-- if $lines->[0] != $lines->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $lines->[0] != $lines->[1] 255 576 831
73  
74 831 $self->{+_INFO} = $info;
75 }
76  
77 1266 return $self->{+_INFO};
78 }
79  
80 0 ▶sub trace {
Subroutine trace: not called CC=2 SCAR=17.9
Pod undocumented
81 0 my $self = shift;
82  
83 0 my ($hub, %params) = @_;
84  
85 0 ▶ croak "'hub' is required"
Branch: 1 branch
BranchTrueFalseTotal
unless $hub 0 0 0
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 0 ▶sub debug {
Subroutine debug: not called CC=2 SCAR=17.9
Pod undocumented
102 0 my $self = shift;
103 0 my $file = $self->file;
104 0 my $lines = $self->lines;
105  
106 0 ▶ my $line_str = @$lines == 1 ? "around line $lines->[0]" : "around lines $lines->[0] -> $lines->[1]";
Branch: 1 branch
BranchTrueFalseTotal
@$lines == 1 ? : 0 0 0
107 0 return "at $file $line_str.";
108 }
109  
110 0 ▶sub throw {
Subroutine throw: not called CC=1 SCAR=6.9
Pod undocumented
111 0 my $self = shift;
112 0 my ($msg) = @_;
113 0 die "$msg " . $self->debug . "\n";
114 }
115  
116 41 1;
117  
118 __END__
« blib/lib/ok.pm ↑ Summary blib/lib/Test2/API/InterceptResult/Squasher.pm »