Util/Underscore/References.pm

filter: Statementstmt 86.2% 25 / 29 Branchbran 90.0% 27 / 30 Conditioncond 68.0% 17 / 25 MC/DCmcdc 61.5% 8 / 13 Subroutinesub 94.1% 16 / 17 Podpod n/a totaltotal 81.5% 93 / 114 CC 25 SCAR 16.0
CC
25
Cov
82%
__ANON__
20.0
is_scalar_ref
5.0
is_array_ref
4.0
CRAP 4.9
« Util/Underscore/ListUtils.pm ↑ Summary Util/Underscore/Scalars.pm »
1 package Util::Underscore::References;
2  
3 #ABSTRACT: Functions for introspecting and manipulating references
4  
5 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 ## no critic (ProhibitMultiplePackages)
10 package # hide from PAUSE
11 _;
12  
13 ## no critic (RequireArgUnpacking, RequireFinalReturn, ProhibitSubroutinePrototypes)
14  
15 sub ref_addr(_) {
16 8 ▶ goto &Scalar::Util::refaddr;
Subroutine ref_addr: called CC=1 SCAR=0.0
17 }
18  
19 sub ref_type(_) {
20 141 ▶ goto &Scalar::Util::reftype;
Subroutine ref_type: called CC=1 SCAR=0.0
21 }
22  
23 BEGIN {
24 # perl 5.10 thinks reftype qr// eq 'SCALAR'.
25 # This is bogus, we'll have to correct that.
26 12 ▶ if ($^V < 5.011) {
Subroutine BEGIN: called CC=2 SCAR=12.5
Branch: 1 branch
BranchTrueFalseTotal
if ($^V < "5.011") 0 12 12
27 12 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 *ref_type = sub (_) {
29 0 ▶ my $type = &Scalar::Util::reftype;
Subroutine __ANON__: not called CC=4 SCAR=30.0
30 0 ▶ return 'REGEXP'
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type eq "SCALAR" and ref $_[0] eq "Regexp" 0 0 0
Condition0%0/6
defined $type and $type eq "SCALAR" and ref $_[0] eq "Regexp"
!ll&&!rl&&r
000
defined $type and $type eq "SCALAR"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $type and $type eq "SCALAR" and ref $_[0] eq "Regexp"
defined $type $type eq "SCALAR" ref $_[0] eq "Regexp"
Truth table0%0/4
A and B and C
A= defined $typeB= $type eq "SCALAR"C= ref $_[0] eq "Regexp"
ABCresult
0XX0
10X0
1100
1111
31 if defined $type
32 and $type eq 'SCALAR'
33 and ref $_[0] eq 'Regexp';
34 0 return $type;
35 0 };
36 }
37 }
38  
39 sub ref_weaken(_) {
40 3 ▶ goto &Scalar::Util::weaken;
Subroutine ref_weaken: called CC=1 SCAR=0.0
41 }
42  
43 sub ref_unweaken(_) {
44 2 ▶ goto &Scalar::Util::unweaken;
Subroutine ref_unweaken: called CC=1 SCAR=0.0
45 }
46  
47 sub ref_is_weak(_) {
48 9 ▶ goto &Scalar::Util::isweak;
Subroutine ref_is_weak: called CC=1 SCAR=0.0
49 }
50  
51 sub is_ref(_) {
52 18 ▶ defined($_[0])
Subroutine is_ref: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] and defined &ref_type($_[0]) and not defined &blessed($_[0]) 14 4 18
Condition100%3/3
defined $_[0] and defined &ref_type($_[0])
!ll&&!rl&&r
2214
MC/DC100%2/2
defined $_[0] and defined &ref_type($_[0])
defined $_[0] defined &ref_type($_[0])
Truth table100%3/3
A and B
A= defined $_[0]B= defined &ref_type($_[0])
ABresult
0X0
100
111
53 && defined ref_type $_[0]
54 && !defined blessed $_[0];
55 }
56  
57 sub is_scalar_ref(_) {
58 defined($_[0])
59 && (
60 (defined blessed $_[0])
61 ? overload::Method($_[0], q[${}])
62 13 ▶ : do {
Subroutine is_scalar_ref: called CC=5 SCAR=16.1
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined &blessed($_[0]) ? overload::Method($_[0], "\${}") : do { my $type = &ref_type($_[0]) // ""; $type eq "SCALAR" or $type eq "REF" } 11 2 13
defined &blessed($_[0]) ? : 2 9 11
63 9 ▶ my $type = ref_type $_[0] // q[];
Condition100%2/2
&ref_type($_[0]) // ""
l!l
72
MC/DC100%1/1
&ref_type($_[0]) // ""
&ref_type($_[0])
Truth table100%2/2
A
A= &ref_type($_[0])
Aresult
11
00
64 9 ▶ $type eq 'SCALAR' || $type eq 'REF';
Branch: 1 branch
BranchTrueFalseTotal
$type eq "SCALAR" or $type eq "REF" 7 2 9
65 }
66 );
67 }
68  
69 sub is_array_ref(_) {
70 16 ▶ defined($_[0])
Subroutine is_array_ref: called CC=4 SCAR=13.9
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined &blessed($_[0]) ? overload::Method($_[0], "\@{}") : (&ref_type($_[0]) // "") eq "ARRAY" 14 2 16
defined &blessed($_[0]) ? : 2 12 14
Condition100%2/2
&ref_type($_[0]) // ""
l!l
102
MC/DC100%1/1
&ref_type($_[0]) // ""
&ref_type($_[0])
Truth table100%2/2
A
A= &ref_type($_[0])
Aresult
11
00
71 && (
72 (defined blessed $_[0])
73 ? overload::Method($_[0], q[@{}])
74 : (ref_type $_[0] // q[]) eq 'ARRAY'
75 );
76 }
77  
78 sub is_hash_ref(_) {
79 12 ▶ defined($_[0])
Subroutine is_hash_ref: called CC=4 SCAR=13.9
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined &blessed($_[0]) ? overload::Method($_[0], "%{}") : (&ref_type($_[0]) // "") eq "HASH" 10 2 12
defined &blessed($_[0]) ? : 2 8 10
Condition100%2/2
&ref_type($_[0]) // ""
l!l
62
MC/DC100%1/1
&ref_type($_[0]) // ""
&ref_type($_[0])
Truth table100%2/2
A
A= &ref_type($_[0])
Aresult
11
00
80 && (
81 (defined blessed $_[0])
82 ? overload::Method($_[0], q[%{}])
83 : (ref_type $_[0] // q[]) eq 'HASH'
84 );
85 }
86  
87 sub is_code_ref(_) {
88 12 ▶ defined($_[0])
Subroutine is_code_ref: called CC=4 SCAR=13.9
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined &blessed($_[0]) ? overload::Method($_[0], "&{}") : (&ref_type($_[0]) // "") eq "CODE" 10 2 12
defined &blessed($_[0]) ? : 2 8 10
Condition100%2/2
&ref_type($_[0]) // ""
l!l
62
MC/DC100%1/1
&ref_type($_[0]) // ""
&ref_type($_[0])
Truth table100%2/2
A
A= &ref_type($_[0])
Aresult
11
00
89 && (
90 (defined blessed $_[0])
91 ? overload::Method($_[0], q[&{}])
92 : (ref_type $_[0] // q[]) eq 'CODE'
93 );
94 }
95  
96 sub is_glob_ref(_) {
97 12 ▶ defined($_[0])
Subroutine is_glob_ref: called CC=4 SCAR=13.9
Branch: 2 branches
BranchTrueFalseTotal
defined $_[0] and defined &blessed($_[0]) ? overload::Method($_[0], "*{}") : (&ref_type($_[0]) // "") eq "GLOB" 10 2 12
defined &blessed($_[0]) ? : 2 8 10
Condition100%2/2
&ref_type($_[0]) // ""
l!l
62
MC/DC100%1/1
&ref_type($_[0]) // ""
&ref_type($_[0])
Truth table100%2/2
A
A= &ref_type($_[0])
Aresult
11
00
98 && (
99 (defined blessed $_[0])
100 ? overload::Method($_[0], q[*{}])
101 : (ref_type $_[0] // q[]) eq 'GLOB'
102 );
103 }
104  
105 sub is_regex(_) {
106 12 ▶ defined(blessed $_[0])
Subroutine is_regex: called CC=3 SCAR=11.3
Branch: 1 branch
BranchTrueFalseTotal
defined &blessed($_[0]) and "REGEXP" eq &ref_type($_[0]) || overload::Method($_[0], "qr") 3 9 12
Condition66%4/6
defined &blessed($_[0]) && ('REGEXP' eq &ref_type($_[0]) || overload::Method($_[0], 'qr'))
!ll&&!rl&&r
903
"REGEXP" eq &ref_type($_[0]) or overload::Method($_[0], "qr")
l!l&&r!l&&!r
210
MC/DC33%1/3
defined &blessed($_[0]) && ('REGEXP' eq &ref_type($_[0]) || overload::Method($_[0], 'qr'))
defined &blessed($_[0]) "REGEXP" eq &ref_type($_[0]) overload::Method($_[0], "qr")
Truth table75%3/4
A && B or C
A= defined &blessed($_[0])B= "REGEXP" eq &ref_type($_[0])C= overload::Method($_[0], "qr")
ABCresult
0XX0
1000
11X1
1011
107 && ('REGEXP' eq ref_type $_[0]
108 || overload::Method($_[0], q[qr]));
109 }
110  
111 12 1;
112  
113 __END__
« Util/Underscore/ListUtils.pm ↑ Summary Util/Underscore/Scalars.pm »