Perlish/Smatch/Undef.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 100% 41 / 41 CC 5 SCAR 5.9
CC
5
Cov
100%
_ARRAY
3.0
_HASH
3.0
BEGIN
1.0
CRAP 1.8
« Perlish/Smatch/Regexp.pm ↑ Summary Perlish/Smatch/Value.pm »
1 package Switch::Perlish::Smatch::Undef;
2  
3 11 $VERSION = '1.0.0';
4  
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ## DESC - Return false as $m is already defined.
11 1 ▶sub _VALUE { return }
Subroutine _VALUE: called CC=1 SCAR=0.0
12  
13 ## DESC - Return true as $m is already undefined.
14 1 ▶sub _UNDEF { return 1 }
Subroutine _UNDEF: called CC=1 SCAR=0.0
15  
16 ## DESC - Check if $$m is undef.
17 2 ▶sub _SCALAR {
Subroutine _SCALAR: called CC=1 SCAR=0.0
18 2 my($t, $m) = @_;
19 2 return !defined($$m);
20 }
21  
22 ## DESC - Check for an undef in @$m.
23 2 ▶sub _ARRAY {
Subroutine _ARRAY: called CC=3 SCAR=11.0
24 2 my($t, $m) = @_;
25 !defined and return 1
26 2 ▶ for @$m;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or return 1 4 1 5
27 1 return;
28 }
29  
30 ## DESC - Check for an undefined value in %$m (better suggestions welcome).
31 2 ▶sub _HASH {
Subroutine _HASH: called CC=3 SCAR=11.0
32 2 my($t, $m) = @_;
33 !defined and return 1
34 2 ▶ for values %$m;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or return 1 2 1 3
35 1 return;
36 }
37  
38 ## DESC - Pass undef to &$m (to be consistent with other CODE comparators).
39 2 ▶sub _CODE {
Subroutine _CODE: called CC=1 SCAR=0.0
40 2 my($t, $m) = @_;
41 2 return $m->($t);
42 }
43  
44 ## DESC - croak("Can't compare undef with OBJECT") # Suggestions welcome.
45 1 ▶sub _OBJECT {
Subroutine _OBJECT: called CC=1 SCAR=0.0
46 1 croak("Can't compare undef with OBJECT");
47 }
48  
49 ## DESC - croak("Can't compare undef with Regexp") # Suggestions welcome.
50 1 ▶sub _Regexp {
Subroutine _Regexp: called CC=1 SCAR=0.0
51 1 croak("Can't compare undef with Regexp");
52 }
53  
54 11 Switch::Perlish::Smatch->register_package( __PACKAGE__, 'UNDEF' );
55  
56 11 1;
57  
58 =pod
59  
60 =head1 NAME
61  
62 Switch::Perlish::Smatch::Undef - The C<UNDEF> comparatory category package.
63  
64 =head1 VERSION
65  
66 1.0.0 - Initial release.
67  
68 =head1 DESCRIPTION
69  
70 This package provides the default implementation for the C<UNDEF> comparator
71 category. For more information on the comparator implementation see.
72 L<Switch::Perlish::Smatch::Comparators/"Undef">.
73  
74 =head1 SEE. ALSO
75  
76 L<Switch::Perlish::Smatch>.
77  
78 =head1 AUTHOR
79  
80 Dan Brook C<< <mr.daniel.brook@gmail.com> >>
81  
82 =head1 COPYRIGHT
83  
84 Copyright (c) 2006, Dan Brook. All Rights Reserved. This module is free
85 software. It may be used, redistributed and/or modified under the same
86 terms as Perl itself.
87  
88 =cut
« Perlish/Smatch/Regexp.pm ↑ Summary Perlish/Smatch/Value.pm »