| 1 | package Test2::Workflow::Task; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use Test2::API(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Test2::Event::Exception(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 40 | ▶ | use List::Util qw/min max/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 40 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 40 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 40 | our @CARP_NOT = qw/Test2::Util::HashBase/; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 40 | ▶ | use base 'Test2::Workflow::BlockBase'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 40 | ▶ | use Test2::Util::HashBase qw/name flat async iso todo skip scaffold events is_root/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | for my $attr (FLAT, ISO, ASYNC, TODO, SKIP, SCAFFOLD) { | |||||||||||||||||||||||||||||||||||||||||
| 19 | 240 | my $old = __PACKAGE__->can("set_$attr"); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 90 | ▶ | my $new = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 90 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 90 | my $out = $self->$old(@_); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 90 | $self->verify_scaffold; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 90 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 240 | }; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 40 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 40 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 240 | *{"set_$attr"} = $new; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 712 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 712 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 712 | ▶ | $self->{+EVENTS} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"events"} ||= []
MC/DC100%1/1
$self->{"events"} ||= []
$self->{"events"}
Truth table100%2/2
A
A= $self->{"events"}
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 712 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 712 | $self->SUPER::init(); | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | $self->throw("the 'name' attribute is required") | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 712 | ▶ | unless $self->{+NAME}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | $self->throw("the 'flat' attribute cannot be combined with 'iso' or 'async'") | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 712 | ▶ | if $self->{+FLAT} && ($self->{+ISO} || $self->{+ASYNC}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->{"flat"} and $self->{"iso"} || $self->{"async"}
$self->{"iso"} or $self->{"async"}
MC/DC0%0/3
$self->{"flat"} and $self->{"iso"} || $self->{"async"}
$self->{"flat"}
$self->{"iso"}
$self->{"async"}
Truth table50%2/4
A and B or C
A= $self->{"flat"}B= $self->{"iso"}C= $self->{"async"}
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 712 | $self->set_subname($self->package . "::<$self->{+NAME}>"); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 712 | $self->verify_scaffold; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 144 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 144 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 144 | return bless {%$self}, blessed($self); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 802 | ▶ | sub verify_scaffold { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_scaffold: called CC=6 SCAR=19.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 802 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 802 | ▶ | return unless $self->{+SCAFFOLD}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | croak "The 'flat' attribute must be true for scaffolding" | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 113 | ▶ | if defined($self->{+FLAT}) && !$self->{+FLAT}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"flat"} and not $self->{"flat"}
MC/DC0%0/2
defined $self->{"flat"} and not $self->{"flat"}
defined $self->{"flat"}
not $self->{"flat"}
Truth table33%1/3
A and not(B)
A= defined $self->{"flat"}B= not $self->{"flat"}
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 113 | $self->{+FLAT} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 113 | for my $attr (ISO, ASYNC, TODO, SKIP) { | |||||||||||||||||||||||||||||||||||||||||
| 69 | croak "The '$attr' attribute cannot be used on scaffolding" | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 452 | ▶ | if $self->{$attr}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub exception { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exception: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my ($err) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $hub = Test2::API::test2_stack->top; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $trace = $self->trace($hub); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $hub->send( | |||||||||||||||||||||||||||||||||||||||||
| 83 | Test2::Event::Exception->new( | ||||||||||||||||||||||||||||||||||||||||||
| 84 | trace => $trace, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | error => $err, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 663 | ▶ | sub filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: called CC=23 SCAR=41.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 663 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 663 | my ($filter) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 663 | ▶ | return unless $filter; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 663 | ▶ | return if $self->{+IS_ROOT}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 663 | ▶ | return if $self->{+SCAFFOLD}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 601 | ▶ | if (my $name = $filter->{name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 398 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 398 | ▶ | unless(ref($name)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 398 | ▶ | $ok ||= $self->{+NAME} eq $name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ok ||= $self->{"name"} eq $name
MC/DC50%1/2
$ok ||= $self->{"name"} eq $name
$ok
$self->{"name"} eq $name
Truth table66%2/3
A ||= B
A= $okB= $self->{"name"} eq $name
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 398 | ▶ | $ok ||= $self->subname eq $name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ok ||= $self->subname eq $name
MC/DC50%1/2
$ok ||= $self->subname eq $name
$ok
$self->subname eq $name
Truth table66%2/3
A ||= B
A= $okB= $self->subname eq $name
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 398 | ▶ | if (ref($name) eq 'Regexp') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $ok ||= $self->{+NAME} =~ $name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ok ||= $self->{"name"} =~ /$name/
MC/DC0%0/2
$ok ||= $self->{"name"} =~ /$name/
$ok
$self->{"name"} =~ /$name/
Truth table0%0/3
A ||= B
A= $okB= $self->{"name"} =~ /$name/
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $ok ||= $self->subname =~ $name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ok ||= $self->subname =~ /$name/
MC/DC0%0/2
$ok ||= $self->subname =~ /$name/
$ok
$self->subname =~ /$name/
Truth table0%0/3
A ||= B
A= $okB= $self->subname =~ /$name/
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | elsif ($name =~ m{^/}) { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $pattern = eval "qr$name" or die "'$name' does not appear to be a valid pattern"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $ok ||= $self->{+NAME} =~ $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ok ||= $self->{"name"} =~ /$pattern/
MC/DC0%0/2
$ok ||= $self->{"name"} =~ /$pattern/
$ok
$self->{"name"} =~ /$pattern/
Truth table0%0/3
A ||= B
A= $okB= $self->{"name"} =~ /$pattern/
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $ok ||= $self->subname =~ $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ok ||= $self->subname =~ /$pattern/
MC/DC0%0/2
$ok ||= $self->subname =~ /$pattern/
$ok
$self->subname =~ /$pattern/
Truth table0%0/3
A ||= B
A= $okB= $self->subname =~ /$pattern/
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 398 | ▶ | return {skip => "Does not match name filter '$name'"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | unless $ok; | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 250 | ▶ | if (my $file = $filter->{file}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return {skip => "Does not match file filter '$file'"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | unless $self->file eq $file; | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 250 | ▶ | if (my $line = $filter->{line}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 203 | my $lines = $self->lines; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 203 | ▶ | return {skip => "Does not match line filter '$line' (no lines)"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$lines and @$lines
MC/DC0%0/2
$lines and @$lines
$lines
@$lines
Truth table33%1/3
A and B
A= $linesB= @$lines
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | unless $lines && @$lines; | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 203 | my $min = min(@$lines); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 203 | my $max = max(@$lines); | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 203 | ▶ | return {skip => "Does not match line filter '$min <= $line <= $max'"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min <= $line and $max >= $line
MC/DC100%2/2
$min <= $line and $max >= $line
$min <= $line
$max >= $line
Truth table100%3/3
A and B
A= $min <= $lineB= $max >= $line
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | unless $min <= $line && $max >= $line; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 78 | return; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | __END__ | ||||||||||||||||||||||||||||||||||||||||||