Aspect/Pointcut/Not.pm

filter: Statementstmt 84.0% 37 / 44 Branchbran 66.6% 12 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 85.7% 6 / 7 totaltotal 80.2% 65 / 81 SCAR 23.9
CC
10
Cov
79%
compile_weave
3.2
curry_weave
3.1
curry_runtime
3.1
CRAP 10.9
« Aspect/Advice/Around.pm ↑ Summary Aspect.pm »
1 package Aspect::Pointcut::Not;
2  
3 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use Aspect::Pointcut::Logic ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 our $VERSION = '0.97_06';
8 21 our @ISA = 'Aspect::Pointcut::Logic';
9  
10  
11  
12  
13  
14 ######################################################################
15 # Constructor
16  
17 sub new {
18 11 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.6
Pod documented
19  
20 # Check the thing we are negating
21 11 ▶ unless ( Params::Util::_INSTANCE($_[0], 'Aspect::Pointcut') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&Params::Util::_INSTANCE($_[0], "Aspect::Pointcut")) 0 11 11
22 0 Carp::croak("Attempted to apply pointcut logic to non-pointcut '$_[0]'");
23 }
24  
25 11 $class->SUPER::new(@_);
26 }
27  
28  
29  
30  
31  
32 ######################################################################
33 # Weaving Methods
34  
35 sub compile_weave {
36 5 ▶ my $child = $_[0]->[0]->compile_weave;
Subroutine compile_weave: called CC=3 SCAR=11.6
Pod documented
37 5 ▶ if ( ref $child ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $child) 0 5 5
38 0 ▶ return sub { not $child->() };
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 }
40 5 ▶ unless ( $child eq '1' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($child eq 1) 2 3 5
41 2 return "not ( $child )";
42 }
43  
44 # When the child matches everything, the negation doesn't negate
45 # the set of things matched. So we match everything too.
46 3 return 1;
47 }
48  
49 sub compile_runtime {
50 3 ▶ my $child = $_[0]->[0]->compile_runtime;
Subroutine compile_runtime: called CC=2 SCAR=8.4
Pod documented
51 3 ▶ if ( ref $child ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $child) { } 0 3 3
52 0 ▶ return sub { not $child->() };
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 } else {
54 3 return "not ( $child )";
55 }
56 }
57  
58 sub match_contains {
59 18 ▶ my $self = shift;
Subroutine match_contains: called CC=2 SCAR=7.1
Pod documented
60 18 my $count = $self->[0]->match_contains($_[0]);
61 18 ▶ return $self->isa($_[0]) ? ++$count : $count;
Branch: 1 branch
BranchTrueFalseTotal
$self->isa($_[0]) ? : 0 18 18
62 }
63  
64 sub match_runtime {
65 5 ▶ $_[0]->[0]->match_runtime;
Subroutine match_runtime: called CC=1 SCAR=0.0
Pod undocumented
66 }
67  
68 # Logical not inherits it's curryability from the element contained
69 # within it. We continue to be needed if and only if something below us
70 # continues to be needed as well.
71 sub curry_weave {
72 5 ▶ my $self = shift;
Subroutine curry_weave: called CC=3 SCAR=11.2
Pod documented
73 5 ▶ my $child = $self->[0]->curry_weave or return;
Branch: 1 branch
BranchTrueFalseTotal
my $child = $self->[0]->curry_weave or return 3 2 5
74  
75 # Handle the special case where the collapsing pointcut results
76 # in a "double not". Fetch the child of our child not and return
77 # it directly.
78 2 ▶ if ( $child->isa('Aspect::Pointcut::Not') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->isa("Aspect::Pointcut::Not")) 0 2 2
79 0 return $child->[0];
80 }
81  
82 # Return our clone with the curried child
83 2 my $class = ref($self);
84 2 return $class->new( $child );
85 }
86  
87 # Logical not inherits it's curryability from the element contained
88 # within it. We continue to be needed if and only if something below us
89 # continues to be needed as well.
90 # For cleanliness (and to avoid accidents) we make a copy of ourself
91 # in case our child curries to something other than it's pure self.
92 sub curry_runtime {
93 5 ▶ my $self = shift;
Subroutine curry_runtime: called CC=3 SCAR=11.2
Pod documented
94 5 ▶ my $child = $self->[0]->curry_runtime or return;
Branch: 1 branch
BranchTrueFalseTotal
my $child = $self->[0]->curry_runtime or return 2 3 5
95  
96 # Handle the special case where the collapsing pointcut results
97 # in a "double not". Fetch the child of our child not and return
98 # it directly.
99 3 ▶ if ( $child->isa('Aspect::Pointcut::Not') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->isa("Aspect::Pointcut::Not")) 0 3 3
100 0 return $child->[0];
101 }
102  
103 # Return our clone with the curried child
104 3 my $class = ref($self);
105 3 return $class->new( $child );
106 }
107  
108 21 1;
109  
110 __END__
« Aspect/Advice/Around.pm ↑ Summary Aspect.pm »