blib/lib/Params/Util/PP.pm

filter: Statementstmt 83.9% 73 / 87 Branchbran 78.4% 69 / 88 Conditioncond 87.3% 124 / 142 MC/DCmcdc 80.8% 55 / 68 Subroutinesub 93.9% 31 / 33 Podpod n/a totaltotal 84.2% 352 / 418 CC 93 SCAR 25.9
CC
93
Cov
84%
__ANON__
110.0
_HANDLE
13.4
_CLASSDOES
6.8
CRAP 13.3
↑ Summary Util.xs »
1 package Params::Util::PP;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 our $VERSION = '1.099_001';
7  
8 =pod
9  
10 =head1 NAME
11  
12 Params::Util::PP - PurePerl Params::Util routines
13  
14 =cut
15  
16 18 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 18 ▶use overload ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 18 ▶Scalar::Util->can("looks_like_number") and Scalar::Util->import("looks_like_number");
Branch: 1 branch
BranchTrueFalseTotal
"Scalar::Util"->can("looks_like_number") and "Scalar::Util"->import("looks_like_number") 18 0 18
20 # Use a private pure-perl copy of looks_like_number if the version of
21 # Scalar::Util is old (for whatever reason).
22 Params::Util::PP->can("looks_like_number") or *looks_like_number = sub {
23 0 ▶ local $_ = shift;
Subroutine __ANON__: not called CC=10 SCAR=47.0
24  
25 # checks from perlfaq4
26 0 ▶ return 0 if !defined($_);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
27 0 ▶ if (ref($_))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) 0 0 0
28 {
29 0 ▶ return overload::Overloaded($_) ? defined(0 + $_) : 0;
Branch: 1 branch
BranchTrueFalseTotal
overload::Overloaded($_) ? : 0 0 0
30 }
31 0 ▶ return 1 if (/^[+-]?[0-9]+$/); # is a +/- integer
Branch: 1 branch
BranchTrueFalseTotal
if /^[+-]?[0-9]+$/ 0 0 0
32 ## no critic (RegularExpressions::ProhibitComplexRegexes)
33 0 ▶ return 1 if (/^(?:[+-]?)(?=[0-9]|\.[0-9])[0-9]*(?:\.[0-9]*)?(?:[Ee](?:[+-]?[0-9]+))?$/); # a C float
Branch: 1 branch
BranchTrueFalseTotal
if /^(?:[+-]?)(?=[0-9]|\.[0-9])[0-9]*(?:\.[0-9]*)?(?:[Ee](?:[+-]?[0-9]+))?$/ 0 0 0
34 0 ▶ return 1 if ($] >= 5.008 and /^(?:Inf(?:inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.008" and /^(?:Inf(?:inity)?|NaN)$/i or $] >= "5.006001" and /^Inf$/i 0 0 0
Condition0%0/9
$] >= "5.008" and /^(?:Inf(?:inity)?|NaN)$/i or $] >= "5.006001" and /^Inf$/i
l!l&&r!l&&!r
000
$] >= "5.008" and /^(?:Inf(?:inity)?|NaN)$/i
!ll&&!rl&&r
000
$] >= "5.006001" and /^Inf$/i
!ll&&!rl&&r
000
MC/DC0%0/4
$] >= "5.008" and /^(?:Inf(?:inity)?|NaN)$/i or $] >= "5.006001" and /^Inf$/i
$] >= "5.008" /^(?:Inf(?:inity)?|NaN)$/i $] >= "5.006001" /^Inf$/i
Truth table0%0/7
A and B or C and D
A= $] >= "5.008"B= /^(?:Inf(?:inity)?|NaN)$/iC= $] >= "5.006001"D= /^Inf$/i
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
35  
36 0 0;
37 18 ▶};
Branch: 1 branch
BranchTrueFalseTotal
"Params::Util::PP"->can("looks_like_number") or *looks_like_number = sub { local $_ = shift(); return 0 unless defined $_; if (ref $_) { return overload::Overloaded($_) ? defined 0 + $_ : 0; } ; return 1 if /^[+-]?[0-9]+$/; return 1 if /^(?:[+-]?)(?=[0-9]|\.[0-9])[0-9]*(?:\.[0-9]*)?(?:[Ee](?:[+-]?[0-9]+))?$/; return 1 if $] >= "5.008" and /^(?:Inf(?:inity)?|NaN)$/i or $] >= "5.006001" and /^Inf$/i; 0; } 0 18 18
38  
39 ## no critic (Subroutines::ProhibitSubroutinePrototypes, Subroutines::RequireArgUnpacking)
40 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
41  
42 0 ▶sub _XScompiled { return 0; }
Subroutine _XScompiled: not called CC=1 SCAR=6.9
43  
44 sub _STRING ($)
45 {
46 50 ▶ my $arg = $_[0];
Subroutine _STRING: called CC=4 SCAR=13.9
47 50 ▶ return (defined $arg and not ref $arg and length($arg)) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && length $arg ? : 36 14 50
Condition100%6/6
defined $arg and not ref $arg and length $arg
!ll&&!rl&&r
12236
defined $arg and not ref $arg
!ll&&!rl&&r
21038
MC/DC100%3/3
defined $arg and not ref $arg and length $arg
defined $arg not ref $arg length $arg
Truth table100%4/4
A and not(B) and C
A= defined $argB= not ref $argC= length $arg
ABCresult
0XX0
10X0
1100
1111
48 }
49  
50 sub _IDENTIFIER ($)
51 {
52 76 ▶ my $arg = $_[0];
Subroutine _IDENTIFIER: called CC=4 SCAR=13.9
53 76 ▶ return (defined $arg and not ref $arg and $arg =~ m/^[^\W\d]\w*\z/s) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && $arg =~ /^[^\W\d]\w*\z/s ? : 32 44 76
Condition100%6/6
defined $arg and not ref $arg and $arg =~ /^[^\W\d]\w*\z/s
!ll&&!rl&&r
242032
defined $arg and not ref $arg
!ll&&!rl&&r
42052
MC/DC100%3/3
defined $arg and not ref $arg and $arg =~ /^[^\W\d]\w*\z/s
defined $arg not ref $arg $arg =~ /^[^\W\d]\w*\z/s
Truth table100%4/4
A and not(B) and C
A= defined $argB= not ref $argC= $arg =~ /^[^\W\d]\w*\z/s
ABCresult
0XX0
10X0
1100
1111
54 }
55  
56 sub _CLASS ($)
57 {
58 152 ▶ my $arg = $_[0];
Subroutine _CLASS: called CC=4 SCAR=13.9
59 152 ▶ return (defined $arg and not ref $arg and $arg =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s ? : 74 78 152
Condition100%6/6
defined $arg and not ref $arg and $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
384074
defined $arg and not ref $arg
!ll&&!rl&&r
632114
MC/DC100%3/3
defined $arg and not ref $arg and $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
defined $arg not ref $arg $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
Truth table100%4/4
A and not(B) and C
A= defined $argB= not ref $argC= $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
ABCresult
0XX0
10X0
1100
1111
60 }
61  
62 sub _CLASSISA ($$)
63 {
64 52 ▶ return (defined $_[0] and not ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->isa($_[1])) ? $_[0] : undef;
Subroutine _CLASSISA: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && !ref($_[0]) && $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s && $_[0]->isa($_[1]) ? : 10 42 52
Condition100%9/9
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->isa($_[1])
!ll&&!rl&&r
241810
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
101428
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
2842
MC/DC100%4/4
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->isa($_[1])
defined $_[0] not ref $_[0] $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s $_[0]->isa($_[1])
Truth table100%5/5
A and not(B) and C and D
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/sD= $_[0]->isa($_[1])
ABCDresult
0XXX0
10XX0
110X0
11100
11111
65 }
66  
67 sub _CLASSDOES ($$)
68 {
69 8 ▶ return (defined $_[0] and not ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->DOES($_[1])) ? $_[0] : undef;
Subroutine _CLASSDOES: called CC=5 SCAR=19.2
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && !ref($_[0]) && $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s && $_[0]->DOES($_[1]) ? : 6 2 8
Condition44%4/9
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->DOES($_[1])
!ll&&!rl&&r
026
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
008
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
008
MC/DC25%1/4
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->DOES($_[1])
defined $_[0] not ref $_[0] $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s $_[0]->DOES($_[1])
Truth table40%2/5
A and not(B) and C and D
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/sD= $_[0]->DOES($_[1])
ABCDresult
0XXX0
10XX0
110X0
11100
11111
70 }
71  
72 sub _SUBCLASS ($$)
73 {
74 52 ▶ return (defined $_[0] and not ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s and $_[0] ne $_[1] and $_[0]->isa($_[1]))
Subroutine _SUBCLASS: called CC=6 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && !ref($_[0]) && $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s && $_[0] ne $_[1] && $_[0]->isa($_[1]) ? : 6 46 52
Condition100%12/12
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0] ne $_[1] and $_[0]->isa($_[1])
!ll&&!rl&&r
28186
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0] ne $_[1]
!ll&&!rl&&r
24424
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
101428
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
2842
MC/DC100%5/5
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s and $_[0] ne $_[1] and $_[0]->isa($_[1])
defined $_[0] not ref $_[0] $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s $_[0] ne $_[1] $_[0]->isa($_[1])
Truth table100%6/6
A and not(B) and C and D and E
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/sD= $_[0] ne $_[1]E= $_[0]->isa($_[1])
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
75 ? $_[0]
76 : undef;
77 }
78  
79 sub _NUMBER ($)
80 {
81 62 ▶ my $arg = $_[0];
Subroutine _NUMBER: called CC=4 SCAR=13.9
82 62 ▶ return (defined $arg and not ref $arg and looks_like_number($arg)) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && &looks_like_number($arg) ? : 44 18 62
Condition100%6/6
defined $arg and not ref $arg and &looks_like_number($arg)
!ll&&!rl&&r
12644
defined $arg and not ref $arg
!ll&&!rl&&r
21050
MC/DC100%3/3
defined $arg and not ref $arg and &looks_like_number($arg)
defined $arg not ref $arg &looks_like_number($arg)
Truth table100%4/4
A and not(B) and C
A= defined $argB= not ref $argC= &looks_like_number($arg)
ABCresult
0XX0
10X0
1100
1111
83 }
84  
85 sub _POSINT ($)
86 {
87 84 ▶ my $arg = $_[0];
Subroutine _POSINT: called CC=4 SCAR=13.9
88 84 ▶ return (defined $arg and not ref $arg and $arg =~ m/^[1-9]\d*$/) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && $arg =~ /^[1-9]\d*$/ ? : 32 52 84
Condition100%6/6
defined $arg and not ref $arg and $arg =~ /^[1-9]\d*$/
!ll&&!rl&&r
242832
defined $arg and not ref $arg
!ll&&!rl&&r
42060
MC/DC100%3/3
defined $arg and not ref $arg and $arg =~ /^[1-9]\d*$/
defined $arg not ref $arg $arg =~ /^[1-9]\d*$/
Truth table100%4/4
A and not(B) and C
A= defined $argB= not ref $argC= $arg =~ /^[1-9]\d*$/
ABCresult
0XX0
10X0
1100
1111
89 }
90  
91 sub _NONNEGINT ($)
92 {
93 88 ▶ my $arg = $_[0];
Subroutine _NONNEGINT: called CC=4 SCAR=13.9
94 88 ▶ return (defined $arg and not ref $arg and $arg =~ m/^(?:0|[1-9]\d*)$/) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && $arg =~ /^(?:0|[1-9]\d*)$/ ? : 40 48 88
Condition100%6/6
defined $arg and not ref $arg and $arg =~ /^(?:0|[1-9]\d*)$/
!ll&&!rl&&r
242440
defined $arg and not ref $arg
!ll&&!rl&&r
42064
MC/DC100%3/3
defined $arg and not ref $arg and $arg =~ /^(?:0|[1-9]\d*)$/
defined $arg not ref $arg $arg =~ /^(?:0|[1-9]\d*)$/
Truth table100%4/4
A and not(B) and C
A= defined $argB= not ref $argC= $arg =~ /^(?:0|[1-9]\d*)$/
ABCresult
0XX0
10X0
1100
1111
95 }
96  
97 sub _SCALAR ($)
98 {
99 24 ▶ return (ref $_[0] eq 'SCALAR' and defined ${$_[0]} and ${$_[0]} ne '') ? $_[0] : undef;
Subroutine _SCALAR: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'SCALAR' && defined ${$_[0];} && ${$_[0];} ne '' ? : 6 18 24
Condition100%6/6
ref $_[0] eq "SCALAR" and defined ${$_[0];} and ${$_[0];} ne ""
!ll&&!rl&&r
1626
ref $_[0] eq "SCALAR" and defined ${$_[0];}
!ll&&!rl&&r
1428
MC/DC100%3/3
ref $_[0] eq "SCALAR" and defined ${$_[0];} and ${$_[0];} ne ""
ref $_[0] eq "SCALAR" defined ${$_[0];} ${$_[0];} ne ""
Truth table100%4/4
A and B and C
A= ref $_[0] eq "SCALAR"B= defined ${$_[0];}C= ${$_[0];} ne ""
ABCresult
0XX0
10X0
1100
1111
100 }
101  
102 sub _SCALAR0 ($)
103 {
104 28 ▶ return ref $_[0] eq 'SCALAR' ? $_[0] : undef;
Subroutine _SCALAR0: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'SCALAR' ? : 14 14 28
105 }
106  
107 sub _ARRAY ($)
108 {
109 68 ▶ return (ref $_[0] eq 'ARRAY' and @{$_[0]}) ? $_[0] : undef;
Subroutine _ARRAY: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' && @{$_[0];} ? : 20 48 68
Condition100%3/3
ref $_[0] eq "ARRAY" and @{$_[0];}
!ll&&!rl&&r
42620
MC/DC100%2/2
ref $_[0] eq "ARRAY" and @{$_[0];}
ref $_[0] eq "ARRAY" @{$_[0];}
Truth table100%3/3
A and B
A= ref $_[0] eq "ARRAY"B= @{$_[0];}
ABresult
0X0
100
111
110 }
111  
112 sub _ARRAY0 ($)
113 {
114 68 ▶ return ref $_[0] eq 'ARRAY' ? $_[0] : undef;
Subroutine _ARRAY0: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 26 42 68
115 }
116  
117 sub _ARRAYLIKE
118 {
119 return (
120 36 ▶ defined $_[0] and ref $_[0] and ((Scalar::Util::reftype($_[0]) eq 'ARRAY')
Subroutine _ARRAYLIKE: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && ref $_[0] && (builtin::reftype($_[0]) eq 'ARRAY' || overload::Method($_[0], '@{}')) ? : 24 12 36
Condition100%9/9
defined $_[0] and ref $_[0] and builtin::reftype($_[0]) eq "ARRAY" || overload::Method($_[0], "\@{}")
!ll&&!rl&&r
6624
defined $_[0] and ref $_[0]
!ll&&!rl&&r
2430
builtin::reftype($_[0]) eq "ARRAY" or overload::Method($_[0], "\@{}")
l!l&&r!l&&!r
12126
MC/DC100%4/4
defined $_[0] and ref $_[0] and builtin::reftype($_[0]) eq "ARRAY" || overload::Method($_[0], "\@{}")
defined $_[0] ref $_[0] builtin::reftype($_[0]) eq "ARRAY" overload::Method($_[0], "\@{}")
Truth table100%5/5
A and B and C or D
A= defined $_[0]B= ref $_[0]C= builtin::reftype($_[0]) eq "ARRAY"D= overload::Method($_[0], "\@{}")
ABCDresult
0XXX0
10XX0
11000
111X1
11011
121 or overload::Method($_[0], '@{}'))
122 ) ? $_[0] : undef;
123 }
124  
125 sub _HASH ($)
126 {
127 22 ▶ return (ref $_[0] eq 'HASH' and scalar %{$_[0]}) ? $_[0] : undef;
Subroutine _HASH: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' && scalar %{$_[0];} ? : 6 16 22
Condition100%2/2
ref $_[0] eq "HASH" and scalar %{$_[0];}
!ll
148
MC/DC100%1/1
ref $_[0] eq "HASH" and scalar %{$_[0];}
ref $_[0] eq "HASH"
Truth table100%2/2
A
A= ref $_[0] eq "HASH"
Aresult
00
11
128 }
129  
130 sub _HASH0 ($)
131 {
132 22 ▶ return ref $_[0] eq 'HASH' ? $_[0] : undef;
Subroutine _HASH0: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 8 14 22
133 }
134  
135 sub _HASHLIKE
136 {
137 return (
138 36 ▶ defined $_[0] and ref $_[0] and ((Scalar::Util::reftype($_[0]) eq 'HASH')
Subroutine _HASHLIKE: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && ref $_[0] && (builtin::reftype($_[0]) eq 'HASH' || overload::Method($_[0], '%{}')) ? : 24 12 36
Condition100%9/9
defined $_[0] and ref $_[0] and builtin::reftype($_[0]) eq "HASH" || overload::Method($_[0], "%{}")
!ll&&!rl&&r
6624
defined $_[0] and ref $_[0]
!ll&&!rl&&r
2430
builtin::reftype($_[0]) eq "HASH" or overload::Method($_[0], "%{}")
l!l&&r!l&&!r
12126
MC/DC100%4/4
defined $_[0] and ref $_[0] and builtin::reftype($_[0]) eq "HASH" || overload::Method($_[0], "%{}")
defined $_[0] ref $_[0] builtin::reftype($_[0]) eq "HASH" overload::Method($_[0], "%{}")
Truth table100%5/5
A and B and C or D
A= defined $_[0]B= ref $_[0]C= builtin::reftype($_[0]) eq "HASH"D= overload::Method($_[0], "%{}")
ABCDresult
0XXX0
10XX0
11000
111X1
11011
139 or overload::Method($_[0], '%{}'))
140 ) ? $_[0] : undef;
141 }
142  
143 sub _CODE ($)
144 {
145 24 ▶ return ref $_[0] eq 'CODE' ? $_[0] : undef;
Subroutine _CODE: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'CODE' ? : 10 14 24
146 }
147  
148 sub _CODELIKE($)
149 {
150 return (
151 17 ▶ (Scalar::Util::reftype($_[0]) || '') eq 'CODE'
Subroutine _CODELIKE: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
(builtin::reftype($_[0]) || '') eq 'CODE' || builtin::blessed($_[0]) && overload::Method($_[0], '&{}') ? : 6 11 17
Condition100%8/8
(builtin::reftype($_[0]) || "") eq "CODE" or builtin::blessed($_[0]) and overload::Method($_[0], "&{}")
l!l&&r!l&&!r
4211
builtin::reftype($_[0]) || ''
l!l
116
builtin::blessed($_[0]) and overload::Method($_[0], "&{}")
!ll&&!rl&&r
832
MC/DC33%1/3
(builtin::reftype($_[0]) || "") eq "CODE" or builtin::blessed($_[0]) and overload::Method($_[0], "&{}")
builtin::reftype($_[0]) builtin::blessed($_[0]) overload::Method($_[0], "&{}")
Truth table50%2/4
A or B and C
A= builtin::reftype($_[0])B= builtin::blessed($_[0])C= overload::Method($_[0], "&{}")
ABCresult
1XX1
0111
00X0
0100
152 or Scalar::Util::blessed($_[0]) and overload::Method($_[0], '&{}')
153 ) ? $_[0] : undef;
154 }
155  
156 sub _INVOCANT($)
157 {
158 return (
159 20 ▶ defined $_[0]
Subroutine _INVOCANT: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && (defined builtin::blessed($_[0]) || &_CLASS($_[0])) ? : 12 8 20
Condition100%6/6
defined $_[0] and defined builtin::blessed($_[0]) || &_CLASS($_[0])
!ll&&!rl&&r
2612
defined builtin::blessed($_[0]) or &_CLASS($_[0])
l!l&&r!l&&!r
846
MC/DC100%3/3
defined $_[0] and defined builtin::blessed($_[0]) || &_CLASS($_[0])
defined $_[0] defined builtin::blessed($_[0]) &_CLASS($_[0])
Truth table100%4/4
A and B or C
A= defined $_[0]B= defined builtin::blessed($_[0])C= &_CLASS($_[0])
ABCresult
0XX0
1000
11X1
1011
160 and (
161 defined Scalar::Util::blessed($_[0])
162 or
163 # We used to check for stash definedness, but any class-like name is a
164 # valid invocant for UNIVERSAL methods, so we stopped. -- rjbs, 2006-07-02
165 _CLASS($_[0])
166 )
167 ) ? $_[0] : undef;
168 }
169  
170 sub _INSTANCE ($$)
171 {
172 81 ▶ return (Scalar::Util::blessed($_[0]) and $_[0]->isa($_[1])) ? $_[0] : undef;
Subroutine _INSTANCE: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) && $_[0]->isa($_[1]) ? : 44 37 81
Condition100%3/3
builtin::blessed($_[0]) and $_[0]->isa($_[1])
!ll&&!rl&&r
261144
MC/DC100%2/2
builtin::blessed($_[0]) and $_[0]->isa($_[1])
builtin::blessed($_[0]) $_[0]->isa($_[1])
Truth table100%3/3
A and B
A= builtin::blessed($_[0])B= $_[0]->isa($_[1])
ABresult
0X0
100
111
173 }
174  
175 sub _INSTANCEDOES ($$)
176 {
177 38 ▶ return (Scalar::Util::blessed($_[0]) and $_[0]->DOES($_[1])) ? $_[0] : undef;
Subroutine _INSTANCEDOES: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) && $_[0]->DOES($_[1]) ? : 36 2 38
Condition66%2/3
builtin::blessed($_[0]) and $_[0]->DOES($_[1])
!ll&&!rl&&r
0236
MC/DC50%1/2
builtin::blessed($_[0]) and $_[0]->DOES($_[1])
builtin::blessed($_[0]) $_[0]->DOES($_[1])
Truth table66%2/3
A and B
A= builtin::blessed($_[0])B= $_[0]->DOES($_[1])
ABresult
0X0
100
111
178 }
179  
180 sub _REGEX ($)
181 {
182 22 ▶ return (defined $_[0] and 'Regexp' eq ref($_[0])) ? $_[0] : undef;
Subroutine _REGEX: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && 'Regexp' eq ref $_[0] ? : 4 18 22
Condition100%3/3
defined $_[0] and "Regexp" eq ref $_[0]
!ll&&!rl&&r
2164
MC/DC100%2/2
defined $_[0] and "Regexp" eq ref $_[0]
defined $_[0] "Regexp" eq ref $_[0]
Truth table100%3/3
A and B
A= defined $_[0]B= "Regexp" eq ref $_[0]
ABresult
0X0
100
111
183 }
184  
185 sub _SET ($$)
186 {
187 44 ▶ my $set_param = shift;
Subroutine _SET: called CC=4 SCAR=13.9
188 44 ▶ _ARRAY($set_param) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
&_ARRAY($set_param) or return undef 32 12 44
189 12 foreach my $item (@$set_param)
190 {
191 12 ▶ _INSTANCE($item, $_[0]) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
&_INSTANCE($item, $_[0]) or return undef 8 4 12
192 }
193 4 return $set_param;
194 }
195  
196 sub _SET0 ($$)
197 {
198 44 ▶ my $set_param = shift;
Subroutine _SET0: called CC=4 SCAR=13.9
199 44 ▶ _ARRAY0($set_param) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
&_ARRAY0($set_param) or return undef 28 16 44
200 16 foreach my $item (@$set_param)
201 {
202 12 ▶ _INSTANCE($item, $_[0]) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
&_INSTANCE($item, $_[0]) or return undef 8 4 12
203 }
204 8 return $set_param;
205 }
206  
207 # We're doing this longhand for now. Once everything is perfect,
208 # we'll compress this into something that compiles more efficiently.
209 # Further, testing file handles is not something that is generally
210 # done millions of times, so doing it slowly is not a big speed hit.
211 sub _HANDLE
212 {
213 30 ▶ my $it = shift;
Subroutine _HANDLE: called CC=10 SCAR=26.0
214  
215 # It has to be defined, of course
216 30 ▶ unless (defined $it)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $it) 2 28 30
217 {
218 2 return undef;
219 }
220  
221 # Normal globs are considered to be file handles
222 28 ▶ if (ref $it eq 'GLOB')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $it eq "GLOB") 6 22 28
223 {
224 6 return $it;
225 }
226  
227 # Check for a normal tied filehandle
228 # Side Note: 5.5.4's tied() and can() doesn't like getting undef
229 22 ▶ if (tied($it) and tied($it)->can('TIEHANDLE'))
Branch: 1 branch
BranchTrueFalseTotal
if (tied $it and tied($it)->can("TIEHANDLE")) 0 22 22
Condition33%1/3
tied $it and tied($it)->can("TIEHANDLE")
!ll&&!rl&&r
2200
MC/DC0%0/2
tied $it and tied($it)->can("TIEHANDLE")
tied $it tied($it)->can("TIEHANDLE")
Truth table33%1/3
A and B
A= tied $itB= tied($it)->can("TIEHANDLE")
ABresult
0X0
100
111
230 {
231 0 return $it;
232 }
233  
234 # There are no other non-object handles that we support
235 22 ▶ unless (Scalar::Util::blessed($it))
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($it)) 20 2 22
236 {
237 20 return undef;
238 }
239  
240 # Check for a common base classes for conventional IO::Handle object
241 2 ▶ if ($it->isa('IO::Handle'))
Branch: 1 branch
BranchTrueFalseTotal
if ($it->isa("IO::Handle")) 0 2 2
242 {
243 0 return $it;
244 }
245  
246 # Check for tied file handles using Tie::Handle
247 2 ▶ if ($it->isa('Tie::Handle'))
Branch: 1 branch
BranchTrueFalseTotal
if ($it->isa("Tie::Handle")) 0 2 2
248 {
249 0 return $it;
250 }
251  
252 # IO::Scalar is not a proper seekable, but it is valid is a
253 # regular file handle
254 2 ▶ if ($it->isa('IO::Scalar'))
Branch: 1 branch
BranchTrueFalseTotal
if ($it->isa("IO::Scalar")) 0 2 2
255 {
256 0 return $it;
257 }
258  
259 # Yet another special case for IO::String, which refuses (for now
260 # anyway) to become a subclass of IO::Handle.
261 2 ▶ if ($it->isa('IO::String'))
Branch: 1 branch
BranchTrueFalseTotal
if ($it->isa("IO::String")) 0 2 2
262 {
263 0 return $it;
264 }
265  
266 # This is not any sort of object we know about
267 2 return undef;
268 }
269  
270 sub _DRIVER ($$)
271 {
272 ## no critic (BuiltinFunctions::ProhibitStringyEval)
273 38 ▶ return (defined _CLASS($_[0]) and eval "require $_[0];" and not $@ and $_[0]->isa($_[1]) and $_[0] ne $_[1]) ? $_[0] : undef;
Subroutine _DRIVER: called CC=6 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
defined &_CLASS($_[0]) && eval "require $_[0];" && !$@ && $_[0]->isa($_[1]) && $_[0] ne $_[1] ? : 4 34 38
Condition91%11/12
defined &_CLASS($_[0]) and eval "require $_[0];" and not $@ and $_[0]->isa($_[1]) and $_[0] ne $_[1]
!ll&&!rl&&r
3224
defined &_CLASS($_[0]) and eval "require $_[0];" and not $@ and $_[0]->isa($_[1])
!ll&&!rl&&r
2846
defined &_CLASS($_[0]) and eval "require $_[0];" and not $@
!ll&&!rl&&r
28010
defined &_CLASS($_[0]) and eval "require $_[0];"
!ll&&!rl&&r
24410
MC/DC80%4/5
defined &_CLASS($_[0]) and eval "require $_[0];" and not $@ and $_[0]->isa($_[1]) and $_[0] ne $_[1]
defined &_CLASS($_[0]) eval "require $_[0];" not $@ $_[0]->isa($_[1]) $_[0] ne $_[1]
Truth table83%5/6
A and B and not(C) and D and E
A= defined &_CLASS($_[0])B= eval "require $_[0];"C= not $@D= $_[0]->isa($_[1])E= $_[0] ne $_[1]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
274 }
275  
276 18 1;
↑ Summary Util.xs »