Number/Tolerant/Type/more_than.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 10 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 96.0% 48 / 50 CC 8 SCAR 12.4
CC
8
Cov
97%
valid_args
5.0
parse
4.0
BEGIN
1.0
CRAP 3.5
« Number/Tolerant/Type/less_than.pm ↑ Summary Number/Tolerant/Type/to.pm »
1 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 # ABSTRACT: a tolerance "m > n"
4  
5 package
6 Number::Tolerant::Type::more_than;
7 25 ▶use parent qw(Number::Tolerant::Type);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 14 ▶sub construct { shift; { value => $_[0], min => $_[0], exclude_min => 1 } }
Subroutine construct: called CC=1 SCAR=0.0
Pod documented
10  
11 25 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
12 25 my ($self, $string, $factory) = @_;
13  
14 25 my $number = $self->number_re;
15 25 my $X = $self->variable_re;
16  
17 25 ▶ return $factory->new(more_than => "$1") if $string =~ m!\A($number)\s*<$X\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s*<$X\z/ 1 24 25
18 24 ▶ return $factory->new(more_than => "$1") if $string =~ m!\A$X?>\s*($number)\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A$X?>\s*($number)\z/ 3 21 24
19  
20 21 ▶ return $factory->new(more_than => "$1")
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\Amore\s+than\s+($number)\z/ 1 20 21
21 if $string =~ m!\Amore\s+than\s+($number)\z!;
22 20 return;
23 }
24  
25 81 ▶sub valid_args {
Subroutine valid_args: called CC=5 SCAR=16.1
Pod documented
26 81 my $self = shift;
27  
28 81 ▶ return unless 2 == grep { defined } @_;
Branch: 1 branch
BranchTrueFalseTotal
unless 2 == grep({defined $_;} @_) 58 23 81
29  
30 23 for my $i ( [0,1], [1,0] ) {
31 38 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i->[0]] eq "more_than" and defined(my $num = $self->normalize_number($_[$i->[1]]))) 14 24 38
Condition66%2/3
$_[$i->[0]] eq "more_than" and defined(my $num = $self->normalize_number($_[$i->[1]]))
!ll&&!rl&&r
24014
MC/DC50%1/2
$_[$i->[0]] eq "more_than" and defined(my $num = $self->normalize_number($_[$i->[1]]))
$_[$i->[0]] eq "more_than" defined(my $num = $self->normalize_number($_[$i->[1]]))
Truth table66%2/3
A and B
A= $_[$i->[0]] eq "more_than"B= defined(my $num = $self->normalize_number($_[$i->[1]]))
ABresult
0X0
100
111
32 $_[ $i->[0] ] eq 'more_than'
33 and defined (my $num = $self->normalize_number($_[ $i->[1] ]))
34 ) {
35 14 return $num;
36 }
37 }
38  
39 9 return;
40 }
41  
42 25 1;
43  
44 __END__
« Number/Tolerant/Type/less_than.pm ↑ Summary Number/Tolerant/Type/to.pm »