blib/lib/Math/Symbolic/Custom/Contains.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 51 / 51 CC 5 SCAR 9.8
CC
5
Cov
100%
contains_operator
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
↑ Summary
1 package Math::Symbolic::Custom::Contains;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp qw/croak carp cluck confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Math::Symbolic::Custom::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶BEGIN { *import = \&Math::Symbolic::Custom::Base::aggregate_import }
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Math::Symbolic::ExportConstants qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 our $VERSION = '1.01';
13  
14 1 our $Aggregate_Export = [qw/contains_operator/];
15  
16 6 ▶sub contains_operator {
Subroutine contains_operator: called CC=5 SCAR=16.1
Pod documented
17 6 my ( $f, $op ) = @_;
18  
19 6 my @nodes = ($f);
20 6 ▶ while (@nodes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@nodes) 12 2 14
21 12 my $n = shift @nodes;
22 12 ▶ if ( ref $n eq 'Math::Symbolic::Operator' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n eq 'Math::Symbolic::Operator') { } 8 4 12
23 8 ▶ if ( not defined $op ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $op) { } 1 7 8
24 1 return $n;
25 }
26 else {
27 7 ▶ if ( $n->type() == $op ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n->type == $op) { } 3 4 7
28 3 return $n;
29 }
30 else {
31 4 my @ops = $n->descending_operands();
32 4 push @nodes, @ops;
33 }
34 }
35 }
36 else {
37 4 next;
38 }
39 }
40 2 return (undef);
41 }
42  
43 1 1;
44 __END__
↑ Summary