| 1 | package Test2::Compare::Array; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 176 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 176 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 176 | ▶ | use base 'Test2::Compare::Base'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 176 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 176 | ▶ | use Test2::Util::HashBase qw/inref meta ending items order for_each/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 176 | ▶ | use Carp qw/croak confess/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 176 | ▶ | use Scalar::Util qw/reftype looks_like_number/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1073 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1073 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1073 | ▶ | if( defined( my $ref = $self->{+INREF}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 447 | ▶ | croak "Cannot specify both 'inref' and 'items'" if $self->{+ITEMS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 446 | ▶ | croak "Cannot specify both 'inref' and 'order'" if $self->{+ORDER}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 445 | ▶ | croak "'inref' must be an array reference, got '$ref'" unless reftype($ref) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 444 | my $order = $self->{+ORDER} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 444 | my $items = $self->{+ITEMS} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 444 | ▶ | for (my $i = 0; $i < @$ref; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1231 | push @$order => $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1231 | $items->{$i} = $ref->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 626 | ▶ | $self->{+ITEMS} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"items"} ||= {}
MC/DC100%1/1
$self->{"items"} ||= {}
$self->{"items"}
Truth table100%2/2
A
A= $self->{"items"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | croak "All indexes listed in the 'items' hashref must be numeric" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 626 | ▶ | if grep { !looks_like_number($_) } keys %{$self->{+ITEMS}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 625 | ▶ | $self->{+ORDER} ||= [sort { $a <=> $b } keys %{$self->{+ITEMS}}]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"order"} ||= [(sort {$a <=> $b;} keys %{$$self{"items"};})]
MC/DC100%1/1
$self->{"order"} ||= [(sort {$a <=> $b;} keys %{$$self{"items"};})]
$self->{"order"}
Truth table100%2/2
A
A= $self->{"order"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | croak "All indexes listed in the 'order' arrayref must be numeric" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 625 | ▶ | if grep { !(looks_like_number($_) || (ref($_) && reftype($_) eq 'CODE')) } @{$self->{+ORDER}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
&looks_like_number($_) || ref $_ && builtin::reftype($_) eq 'CODE'
ref $_ and builtin::reftype($_) eq "CODE"
MC/DC66%2/3
&looks_like_number($_) || ref $_ && builtin::reftype($_) eq 'CODE'
&looks_like_number($_)
ref $_
builtin::reftype($_) eq "CODE"
Truth table75%3/4
A || B and C
A= &looks_like_number($_)B= ref $_C= builtin::reftype($_) eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1068 | ▶ | $self->{+FOR_EACH} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"for_each"} ||= []
MC/DC0%0/1
$self->{"for_each"} ||= []
$self->{"for_each"}
Truth table50%1/2
A
A= $self->{"for_each"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1068 | $self->SUPER::init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 21 | ▶ | sub name { '<ARRAY>' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | sub meta_class { 'Test2::Compare::Meta' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1059 | ▶ | sub verify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1059 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1059 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1059 | ▶ | return 0 unless $params{exists}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1056 | my $got = $params{got}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1056 | ▶ | return 0 unless defined $got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1054 | ▶ | return 0 unless ref($got); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1049 | ▶ | return 0 unless reftype($got) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1041 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | sub add_prop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_prop: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | $self->{+META} = $self->meta_class->new unless defined $self->{+META}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | $self->{+META}->add_prop(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1988 | ▶ | sub top_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_index: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1988 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1988 | my @order = @{$self->{+ORDER}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1988 | ▶ | while(@order) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1409 | my $idx = pop @order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1409 | ▶ | next if ref $idx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1392 | return $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 596 | return undef; # No indexes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1983 | ▶ | sub add_item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_item: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1983 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1983 | my $check = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1983 | my ($idx) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1983 | my $top = $self->top_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1983 | ▶ | croak "elements must be added in order!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$top and $idx and $idx <= $top
$top and $idx
MC/DC100%3/3
$top and $idx and $idx <= $top
$top
$idx
$idx <= $top
Truth table100%4/4
A and B and C
A= $topB= $idxC= $idx <= $top
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | if $top && $idx && $idx <= $top; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1982 | ▶ | $idx = defined($top) ? $top + 1 : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | unless defined($idx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1982 | push @{$self->{+ORDER}} => $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1982 | $self->{+ITEMS}->{$idx} = $check; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 23 | ▶ | sub add_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_filter: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 23 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 23 | ▶ | croak "A single coderef is required" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
@_ == 1 and $code and ref $code and builtin::reftype($code) eq "CODE"
@_ == 1 and $code and ref $code
@_ == 1 and $code
MC/DC100%4/4
@_ == 1 and $code and ref $code and builtin::reftype($code) eq "CODE"
@_ == 1
$code
ref $code
builtin::reftype($code) eq "CODE"
Truth table100%5/5
A and B and C and D
A= @_ == 1B= $codeC= ref $codeD= builtin::reftype($code) eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | unless @_ == 1 && $code && ref $code && reftype($code) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 18 | push @{$self->{+ORDER}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 18 | ▶ | sub add_for_each { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_for_each: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 18 | push @{$self->{+FOR_EACH}} => @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 606 | ▶ | sub verify_build { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_build: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 606 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 606 | ▶ | return unless @{$self->{+FOR_EACH}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 17 | ▶ | return unless $self->{+ENDING}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 10 | ▶ | return if keys %{$self->{+ITEMS}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | $self->throw_build_error("'end' with no items specified requires an empty array, which discards the 'all_items' checks; use 'etc' instead of 'end' to check every item without bounding the array"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1047 | ▶ | sub deltas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deltas: called CC=17 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1047 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1047 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1047 | my ($got, $convert, $seen) = @params{qw/got convert seen/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1047 | my @deltas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1047 | my $state = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1047 | my @order = @{$self->{+ORDER}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1047 | my $items = $self->{+ITEMS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1047 | my $for_each = $self->{+FOR_EACH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1047 | my $meta = $self->{+META}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1047 | ▶ | push @deltas => $meta->deltas(%params) if defined $meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Make a copy that we can munge as needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1047 | my @list = @$got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1047 | ▶ | while (@order) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3247 | my $idx = shift @order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3247 | my $overflow = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3247 | my $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # We have a filter, not an index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 3247 | ▶ | if (ref($idx)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 18 | @list = $idx->(@list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 18 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3229 | ▶ | confess "Internal Error: Stacks are out of sync (state > idx)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | if $state > $idx + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 3229 | ▶ | while ($state <= $idx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3234 | $overflow = !@list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3234 | $val = shift @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # check-all goes here so we hit each item, even unspecified ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 3234 | for my $check (@$for_each) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 16 | ▶ | last if $overflow; # avoid doing 'for each' checks beyond array bounds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 15 | $check = $convert->($check); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 15 | ▶ | push @deltas => $check->run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | id => [ARRAY => $state], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | convert => $convert, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | seen => $seen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | exists => !$overflow, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $overflow ? () : (got => $val), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3234 | $state++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3229 | ▶ | confess "Internal Error: Stacks are out of sync (state != idx + 1)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | unless $state == $idx + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3229 | my $check = $convert->($items->{$idx}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3229 | ▶ | push @deltas => $check->run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | id => [ARRAY => $idx], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | convert => $convert, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | seen => $seen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | exists => !$overflow, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $overflow ? () : (got => $val), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1047 | ▶ | while (@list && (@$for_each || $self->{+ENDING})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@list and @$for_each || $self->{"ending"}
@$for_each or $self->{"ending"}
MC/DC100%3/3
@list and @$for_each || $self->{"ending"}
@list
@$for_each
$self->{"ending"}
Truth table100%4/4
A and B or C
A= @listB= @$for_eachC= $self->{"ending"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 17 | my $item = shift @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 17 | for my $check (@$for_each) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 11 | $check = $convert->($check); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 11 | push @deltas => $check->run( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | id => [ARRAY => $state], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | convert => $convert, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | seen => $seen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | got => $item, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | exists => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # if items are left over, and ending is true, we have a problem! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 17 | ▶ | if ($self->{+ENDING}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | push @deltas => $self->delta_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | dne => 'check', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | verified => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | id => [ARRAY => $state], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | got => $item, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | check => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 11 | ▶ | $self->{+ENDING} eq 'implicit' ? (note => 'implicit end') : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 17 | $state++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1047 | return @deltas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 176 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||