blib/lib/NEXT.pm

filter: Statementstmt 89.6% 155 / 173 Branchbran 79.0% 49 / 62 Conditioncond 65.0% 26 / 40 MC/DCmcdc 33.3% 8 / 24 Subroutinesub 100% 18 / 18 Podpod n/a totaltotal 80.7% 256 / 317 CC 49 SCAR 33.2
CC
49
Cov
84%
__ANON__
55.3
__ANON__
25.1
ordered_ancestors
4.0
CRAP 27.6
↑ Summary
1 package NEXT;
2  
3 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use overload ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 our $VERSION = '0.69';
9  
10 sub NEXT::ELSEWHERE::ancestors
11 22 ▶{
Subroutine ancestors: called CC=2 SCAR=6.9
12 22 my @inlist = shift;
13 22 my @outlist = ();
14 22 ▶ while (my $next = shift @inlist) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $next = shift @inlist) 132 22 154
15 132 push @outlist, $next;
16 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 132 unshift @inlist, @{"$outlist[-1]::ISA"};
18 }
19 22 return @outlist;
20 }
21  
22 sub NEXT::ELSEWHERE::ordered_ancestors
23 3 ▶{
Subroutine ordered_ancestors: called CC=4 SCAR=13.9
24 3 my @inlist = shift;
25 3 my @outlist = ();
26 3 ▶ while (my $next = shift @inlist) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $next = shift @inlist) 7 3 10
27 7 push @outlist, $next;
28 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 7 push @inlist, @{"$outlist[-1]::ISA"};
30 }
31 3 ▶ return sort { $a->isa($b) ? -1
Branch: 2 branches
BranchTrueFalseTotal
$a->isa($b) ? : 4 2 6
$b->isa($a) ? : 2 0 2
32 : $b->isa($a) ? +1
33 : 0 } @outlist;
34 }
35  
36 sub NEXT::ELSEWHERE::buildAUTOLOAD
37 48 ▶{
Subroutine buildAUTOLOAD: called CC=1 SCAR=0.0
38 48 my $autoload_name = caller() . '::AUTOLOAD';
39  
40 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
41 48 ▶ *{$autoload_name} = sub {
Subroutine __ANON__: called CC=25 SCAR=32.2
42 54 my ($self) = @_;
43 54 my $depth = 1;
44 54 ▶ until (((caller($depth))[3]||q{}) !~ /^\(eval\)$/) { $depth++ }
Branch: 1 branch
BranchTrueFalseTotal
unless (not +((caller $depth)[3] || "") =~ /^\(eval\)$/) 1 54 55
Condition50%1/2
(caller $depth)[3] || ''
l!l
550
MC/DC0%0/1
(caller $depth)[3] || ''
(caller $depth)[3]
Truth table50%1/2
A
A= (caller $depth)[3]
Aresult
11
00
45 54 my $caller = (caller($depth))[3];
46 54 ▶ my $wanted = $NEXT::AUTOLOAD || $autoload_name;
Condition66%2/3
$NEXT::AUTOLOAD || $autoload_name
l!l&&r!l&&!r
44100
MC/DC0%0/2
$NEXT::AUTOLOAD || $autoload_name
$NEXT::AUTOLOAD $autoload_name
Truth table66%2/3
A || B
A= $NEXT::AUTOLOADB= $autoload_name
ABresult
1X1
011
000
47 54 undef $NEXT::AUTOLOAD;
48 54 my ($caller_class, $caller_method) = do { $caller =~ m{(.*)::(.*)}g };
49 54 my ($wanted_class, $wanted_method) = do { $wanted =~ m{(.*)::(.*)}g };
50 54 ▶ croak "Can't call $wanted from $caller"
Branch: 1 branch
BranchTrueFalseTotal
unless $caller_method eq $wanted_method 3 51 54
51 unless $caller_method eq $wanted_method;
52  
53 51 ▶ my $key = ref $self && overload::Overloaded($self)
Branch: 1 branch
BranchTrueFalseTotal
ref $self && overload::Overloaded($self) ? : 0 51 51
Condition66%2/3
ref $self and overload::Overloaded($self)
!ll&&!rl&&r
2490
MC/DC0%0/2
ref $self and overload::Overloaded($self)
ref $self overload::Overloaded($self)
Truth table66%2/3
A and B
A= ref $selfB= overload::Overloaded($self)
ABresult
0X0
100
111
54 ? overload::StrVal($self) : $self;
55  
56 local ($NEXT::NEXT{$key,$wanted_method}, $NEXT::SEEN) =
57 51 ($NEXT::NEXT{$key,$wanted_method}, $NEXT::SEEN);
58  
59 51 ▶ unless ($NEXT::NEXT{$key,$wanted_method}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($NEXT::NEXT{join $;, $key, $wanted_method}) 22 29 51
60 22 ▶ my @forebears =
Condition66%2/3
ref $self || $self
l!l&&r!l&&!r
2020
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table66%2/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
61 NEXT::ELSEWHERE::ancestors ref $self || $self,
62 $wanted_class;
63 22 ▶ while (@forebears) {
Branch: 1 branch
BranchTrueFalseTotal
if (@forebears) 35 0 35
64 35 ▶ last if shift @forebears eq $caller_class
Branch: 1 branch
BranchTrueFalseTotal
if shift @forebears eq $caller_class 22 13 35
65 }
66 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
67 # Use *{"..."} when first accessing the CODE slot, to make sure
68 # any typeglob stub is upgraded to a full typeglob.
69 17 @{$NEXT::NEXT{$key,$wanted_method}} =
70 map {
71 22 ▶ my $stash = \%{"${_}::"};
Branch: 1 branch
BranchTrueFalseTotal
unless $wanted_method eq "AUTOLOAD" 17 5 22
72 49 ($stash->{$caller_method} && (*{"${_}::$caller_method"}{CODE}))
73 47 ? *{$stash->{$caller_method}}{CODE}
74 73 ▶ : () } @forebears
Branch: 1 branch
BranchTrueFalseTotal
$stash->{$caller_method} && *{"${_}::$caller_method";}{'CODE'} ? : 47 26 73
Condition100%2/2
$stash->{$caller_method} and *{"${_}::$caller_method";}{"CODE"}
!ll
2449
MC/DC100%1/1
$stash->{$caller_method} and *{"${_}::$caller_method";}{"CODE"}
$stash->{$caller_method}
Truth table100%2/2
A
A= $stash->{$caller_method}
Aresult
00
11
75 unless $wanted_method eq 'AUTOLOAD';
76 8 @{$NEXT::NEXT{$key,$wanted_method}} =
77 map {
78 35 my $stash = \%{"${_}::"};
79 35 ▶ ($stash->{AUTOLOAD} && (*{"${_}::AUTOLOAD"}{CODE}))
Branch: 1 branch
BranchTrueFalseTotal
$stash->{'AUTOLOAD'} && *{"${_}::AUTOLOAD";}{'CODE'} ? : 21 14 35
Condition100%2/2
$stash->{"AUTOLOAD"} and *{"${_}::AUTOLOAD";}{"CODE"}
!ll
1025
MC/DC100%1/1
$stash->{"AUTOLOAD"} and *{"${_}::AUTOLOAD";}{"CODE"}
$stash->{"AUTOLOAD"}
Truth table100%2/2
A
A= $stash->{"AUTOLOAD"}
Aresult
00
11
80 ? "${_}::AUTOLOAD"
81 : () } @forebears
82 22 ▶ unless @{$NEXT::NEXT{$key,$wanted_method}||[]};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$NEXT::NEXT{join $;, $key, $wanted_method} or [];} 8 14 22
Condition100%2/2
$NEXT::NEXT{join $;, $key, $wanted_method} || []
l!l
175
MC/DC100%1/1
$NEXT::NEXT{join $;, $key, $wanted_method} || []
$NEXT::NEXT{join $;, $key, $wanted_method}
Truth table100%2/2
A
A= $NEXT::NEXT{join $;, $key, $wanted_method}
Aresult
11
00
83 22 $NEXT::SEEN->{$key,*{$caller}{CODE}}++;
84 }
85 51 my $call_method = shift @{$NEXT::NEXT{$key,$wanted_method}};
86 51 ▶ while (do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ }
Branch: 1 branch
BranchTrueFalseTotal
if (do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ } and defined $call_method and $$NEXT::SEEN{join $;, $key, $call_method}++) 9 51 60
Condition100%6/6
do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ } and defined $call_method and $$NEXT::SEEN{join $;, $key, $call_method}++
!ll&&!rl&&r
4389
do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ } and defined $call_method
!ll&&!rl&&r
40317
MC/DC100%3/3
do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ } and defined $call_method and $$NEXT::SEEN{join $;, $key, $call_method}++
do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ } defined $call_method $$NEXT::SEEN{join $;, $key, $call_method}++
Truth table100%4/4
A and B and C
A= do { $wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/ }B= defined $call_methodC= $$NEXT::SEEN{join $;, $key, $call_method}++
ABCresult
0XX0
10X0
1100
1111
87 && defined $call_method
88 && $NEXT::SEEN->{$key,$call_method}++) {
89 9 $call_method = shift @{$NEXT::NEXT{$key,$wanted_method}};
90 }
91 51 ▶ unless (defined $call_method) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $call_method) 7 44 51
92 7 ▶ return unless do { $wanted_class =~ /^NEXT:.*:ACTUAL/ };
Branch: 1 branch
BranchTrueFalseTotal
unless do { $wanted_class =~ /^NEXT:.*:ACTUAL/ } 5 2 7
93 2 (local $Carp::CarpLevel)++;
94 2 croak qq(Can't locate object method "$wanted_method" ),
95 qq(via package "$caller_class");
96 };
97 44 ▶ return $self->$call_method(@_[1..$#_]) if ref $call_method eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $call_method eq "CODE" 34 10 44
98 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
99 10 ▶ do { ($wanted_method=${$caller_class."::AUTOLOAD"}) =~ s/.*::// }
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_method eq "AUTOLOAD") 8 2 10
100 if $wanted_method eq 'AUTOLOAD';
101 10 $$call_method = $caller_class."::NEXT::".$wanted_method;
102 10 return $call_method->(@_);
103 48 };
104 }
105  
106 6 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
107 6 package NEXT; NEXT::ELSEWHERE::buildAUTOLOAD();
108 6 package NEXT::UNSEEN; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
109 6 package NEXT::DISTINCT; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
110 6 package NEXT::ACTUAL; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
111 6 package NEXT::ACTUAL::UNSEEN; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
112 6 package NEXT::ACTUAL::DISTINCT; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
113 6 package NEXT::UNSEEN::ACTUAL; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
114 6 package NEXT::DISTINCT::ACTUAL; @ISA = 'NEXT'; NEXT::ELSEWHERE::buildAUTOLOAD();
115  
116 package
117 EVERY;
118  
119 12 ▶sub EVERY::ELSEWHERE::buildAUTOLOAD {
Subroutine buildAUTOLOAD: called CC=1 SCAR=0.6
120 12 my $autoload_name = caller() . '::AUTOLOAD';
121  
122 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
123 12 ▶ *{$autoload_name} = sub {
Subroutine __ANON__: called CC=21 SCAR=40.1
124 5 my ($self) = @_;
125 5 my $depth = 1;
126 0 ▶ until (((caller($depth))[3]||q{}) !~ /^\(eval\)$/) { $depth++ }
Branch: 1 branch
BranchTrueFalseTotal
unless (not +((caller $depth)[3] || "") =~ /^\(eval\)$/) 0 5 5
Condition50%1/2
(caller $depth)[3] || ''
l!l
50
MC/DC0%0/1
(caller $depth)[3] || ''
(caller $depth)[3]
Truth table50%1/2
A
A= (caller $depth)[3]
Aresult
11
00
127 5 my $caller = (caller($depth))[3];
128 5 ▶ my $wanted = $EVERY::AUTOLOAD || $autoload_name;
Condition33%1/3
$AUTOLOAD || $autoload_name
l!l&&r!l&&!r
500
MC/DC0%0/2
$AUTOLOAD || $autoload_name
$AUTOLOAD $autoload_name
Truth table33%1/3
A || B
A= $AUTOLOADB= $autoload_name
ABresult
1X1
011
000
129 5 undef $EVERY::AUTOLOAD;
130 5 my ($wanted_class, $wanted_method) = do { $wanted =~ m{(.*)::(.*)}g };
131  
132 5 ▶ my $key = ref($self) && overload::Overloaded($self)
Branch: 1 branch
BranchTrueFalseTotal
ref $self && overload::Overloaded($self) ? : 1 4 5
Condition66%2/3
ref $self and overload::Overloaded($self)
!ll&&!rl&&r
041
MC/DC50%1/2
ref $self and overload::Overloaded($self)
ref $self overload::Overloaded($self)
Truth table66%2/3
A and B
A= ref $selfB= overload::Overloaded($self)
ABresult
0X0
100
111
133 ? overload::StrVal($self) : $self;
134  
135 local $NEXT::ALREADY_IN_EVERY{$key,$wanted_method} =
136 5 $NEXT::ALREADY_IN_EVERY{$key,$wanted_method};
137  
138 5 ▶ return if $NEXT::ALREADY_IN_EVERY{$key,$wanted_method}++;
Branch: 1 branch
BranchTrueFalseTotal
if $NEXT::ALREADY_IN_EVERY{join $;, $key, $wanted_method}++ 2 3 5
139  
140 3 ▶ my @forebears = NEXT::ELSEWHERE::ordered_ancestors ref $self || $self,
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
300
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
141 $wanted_class;
142 3 ▶ @forebears = reverse @forebears if do { $wanted_class =~ /\bLAST\b/ };
Branch: 1 branch
BranchTrueFalseTotal
if do { $wanted_class =~ /\bLAST\b/ } 2 1 3
143 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
144 3 my %seen;
145 3 ▶ my @every = map { my $sub = "${_}::$wanted_method";
Branch: 1 branch
BranchTrueFalseTotal
unless $wanted_method eq "AUTOLOAD" 3 0 3
146 7 ▶ !*{$sub}{CODE} || $seen{$sub}++ ? () : $sub
Branch: 1 branch
BranchTrueFalseTotal
!*{$sub;}{'CODE'} || $seen{$sub}++ ? : 2 5 7
Condition66%2/3
not *{$sub;}{"CODE"} or $seen{$sub}++
l!l&&r!l&&!r
205
MC/DC50%1/2
not *{$sub;}{"CODE"} or $seen{$sub}++
not *{$sub;}{"CODE"} $seen{$sub}++
Truth table66%2/3
not(A) or B
A= not *{$sub;}{"CODE"}B= $seen{$sub}++
ABresult
1X1
011
000
147 } @forebears
148 unless $wanted_method eq 'AUTOLOAD';
149  
150 3 my $want = wantarray;
151 3 ▶ if (@every) {
Branch: 1 branch
BranchTrueFalseTotal
if (@every) 3 0 3
152 3 ▶ if ($want) {
Branch: 2 branches
BranchTrueFalseTotal
if ($want) { } 1 2 3
elsif (defined $want) { } 2 0 2
153 1 return map {($_, [$self->$_(@_[1..$#_])])} @every;
154 }
155 elsif (defined $want) {
156 2 return { map {($_, scalar($self->$_(@_[1..$#_])))}
157 @every
158 };
159 }
160 else {
161 0 $self->$_(@_[1..$#_]) for @every;
162 0 return;
163 }
164 }
165  
166 0 @every = map { my $sub = "${_}::AUTOLOAD";
167 0 ▶ !*{$sub}{CODE} || $seen{$sub}++ ? () : "${_}::AUTOLOAD"
Branch: 1 branch
BranchTrueFalseTotal
!*{$sub;}{'CODE'} || $seen{$sub}++ ? : 0 0 0
Condition0%0/3
not *{$sub;}{"CODE"} or $seen{$sub}++
l!l&&r!l&&!r
000
MC/DC0%0/2
not *{$sub;}{"CODE"} or $seen{$sub}++
not *{$sub;}{"CODE"} $seen{$sub}++
Truth table0%0/3
not(A) or B
A= not *{$sub;}{"CODE"}B= $seen{$sub}++
ABresult
1X1
011
000
168 } @forebears;
169 0 ▶ if ($want) {
Branch: 2 branches
BranchTrueFalseTotal
if ($want) { } 0 0 0
elsif (defined $want) { } 0 0 0
170 0 return map { $$_ = ref($self)."::EVERY::".$wanted_method;
171 0 ($_, [$self->$_(@_[1..$#_])]);
172 } @every;
173 }
174 elsif (defined $want) {
175 0 return { map { $$_ = ref($self)."::EVERY::".$wanted_method;
176 0 ($_, scalar($self->$_(@_[1..$#_])))
177 } @every
178 };
179 }
180 else {
181 0 for (@every) {
182 0 $$_ = ref($self)."::EVERY::".$wanted_method;
183 0 $self->$_(@_[1..$#_]);
184 }
185 0 return;
186 }
187 12 };
188 }
189  
190 6 package EVERY::LAST; @ISA = 'EVERY'; EVERY::ELSEWHERE::buildAUTOLOAD();
191 package
192 6 EVERY; @ISA = 'NEXT'; EVERY::ELSEWHERE::buildAUTOLOAD();
193  
194 6 1;
195  
196 __END__
↑ Summary