| 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')
}
}
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')
}
}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | croak "The 'frame' attribute is required" | ||||||||||||||||||||||||||||
| 38 | 712 | ▶ | unless $self->{+FRAME}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | $self->{+_LINES} = delete $self->{lines} | ||||||||||||||||||||||||||||
| 41 | 712 | ▶ | if $self->{lines}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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"} ||= []
MC/DC0%0/1
$info->{"lines"} ||= []
$info->{"lines"}
Truth table50%1/2
A
A= $info->{"lines"}
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 831 | ▶ | if ($pre_lines && @$pre_lines) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pre_lines and @$pre_lines
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
| |||||||||||||||||||||||||||||
| 62 | 0 | @$lines = @$pre_lines; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||
| 65 | 831 | ▶ | @$lines = ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||