C3/next.pm

filter: Statementstmt 92.8% 13 / 14 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 72.7% 8 / 11 Podpod n/a totaltotal 75.0% 21 / 28 CC 2 SCAR 11.0
CC
2
Cov
81%
method
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« C3.pm ↑ Summary
1 package # hide me from PAUSE
2 next;
3  
4 1 ▶use strict;
Subroutine BEGIN: called
5 1 ▶use warnings;
Subroutine BEGIN: called
6 1 ▶no warnings 'redefine'; # for 00load.t w/ core support
Subroutine BEGIN: called
7  
8 1 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called
9  
10 1 our $VERSION = '0.35';
11  
12 1 our %METHOD_CACHE;
13  
14 0 ▶sub method {
Subroutine method: not called
15 my $self = $_[0];
16 my $class = blessed($self) || $self;
17 my $indirect = caller() =~ /^(?:next|maybe::next)$/;
18 my $level = $indirect ? 2 : 1;
19  
20 my ($method_caller, $label, @label);
21 while ($method_caller = (caller($level++))[3]) {
22 @label = (split '::', $method_caller);
23 $label = pop @label;
24 last unless
25 $label eq '(eval)' ||
26 $label eq '__ANON__';
27 }
28  
29 my $method;
30  
31 my $caller = join '::' => @label;
32  
33 $method = $METHOD_CACHE{"$class|$caller|$label"} ||= do {
34  
35 my @MRO = Class::C3::calculateMRO($class);
36  
37 my $current;
38 while ($current = shift @MRO) {
39 last if $caller eq $current;
40 }
41  
42 1 ▶ no strict 'refs';
Subroutine BEGIN: called
43 my $found;
44 foreach my $class (@MRO) {
45 next if (defined $Class::C3::MRO{$class} &&
46 defined $Class::C3::MRO{$class}{methods}{$label});
47 last if (defined ($found = *{$class . '::' . $label}{CODE}));
48 }
49  
50 $found;
51 };
52  
53 return $method if $indirect;
54  
55 die "No next::method '$label' found for $self" if !$method;
56  
57 goto &{$method};
58 }
59  
60 0 ▶sub can { method($_[0]) }
Subroutine can: not called
61  
62 package # hide me from PAUSE
63 maybe::next;
64  
65 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 1 ▶no warnings 'redefine'; # for 00load.t w/ core support
Subroutine BEGIN: called CC=1 SCAR=0.0
68  
69 1 our $VERSION = '0.35';
70  
71 0 ▶sub method { (next::method($_[0]) || return)->(@_) }
Subroutine method: not called CC=2 SCAR=17.9
Condition0%0/2
next::method($_[0]) || (return)
l!l
00
MC/DC0%0/1
next::method($_[0]) || (return)
next::method($_[0])
Truth table0%0/2
A
A= next::method($_[0])
Aresult
11
00
72  
73 1 1;
74  
75 __END__
« C3.pm ↑ Summary