lib/Lingy/Lang/Numbers.pm

filter: Statementstmt 20.6% 13 / 63 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 23.5% 4 / 17 Podpod 0.0% 0 / 13 totaltotal 12.0% 17 / 141 CC 21 SCAR 44.6
CC
21
Cov
12%
equiv
182.0
range
90.0
add
2.0
CRAP 86.5
« lib/Lingy/Lang/Fn.pm ↑ Summary lib/Lingy/Reader.pm »
1 1 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Lingy::Lang::Numbers;
3  
4 1 ▶use Lingy::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use constant NAME => 'lingy.lang.Numbers';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub add { $_[0] + $_[1] }
Subroutine add: not called CC=1 SCAR=6.9
Pod undocumented
9  
10 0 ▶sub divide { $_[0] / $_[1] }
Subroutine divide: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 sub equiv {
13 0 ▶ my ($x, $y) = @_;
Subroutine equiv: not called CC=13 SCAR=52.0
Pod undocumented
14 0 ▶ return false
Branch: 1 branch
BranchTrueFalseTotal
unless $x->isa("Lingy::Lang::ListClass") and $y->isa("Lingy::Lang::ListClass") or ref $x eq ref $y 0 0 0
Condition0%0/6
$x->isa("Lingy::Lang::ListClass") and $y->isa("Lingy::Lang::ListClass") or ref $x eq ref $y
l!l&&r!l&&!r
000
$x->isa("Lingy::Lang::ListClass") and $y->isa("Lingy::Lang::ListClass")
!ll&&!rl&&r
000
MC/DC0%0/3
$x->isa("Lingy::Lang::ListClass") and $y->isa("Lingy::Lang::ListClass") or ref $x eq ref $y
$x->isa("Lingy::Lang::ListClass") $y->isa("Lingy::Lang::ListClass") ref $x eq ref $y
Truth table0%0/5
A and B or C
A= $x->isa("Lingy::Lang::ListClass")B= $y->isa("Lingy::Lang::ListClass")C= ref $x eq ref $y
ABCresult
11X1
0X11
1011
0X00
1000
15 unless
16 (
17 $x->isa(LISTTYPE) and
18 $y->isa(LISTTYPE)
19 ) or ref($x) eq ref($y);
20 0 ▶ if ($x->isa(LISTTYPE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->isa("Lingy::Lang::ListClass")) 0 0 0
21 0 ▶ return false unless @$x == @$y;
Branch: 1 branch
BranchTrueFalseTotal
unless @$x == @$y 0 0 0
22 0 ▶ for (my $i = 0; $i < @$x; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$x) 0 0 0
23 0 my $bool = equiv($x->[$i], $y->[$i]);
24 0 ▶ return false if "$bool" eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if "$bool" eq 0 0 0 0
25 }
26 0 return true;
27 }
28 0 ▶ if ($x->isa(HASHMAP)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->isa("Lingy::Lang::HashMap")) 0 0 0
29 0 my @xkeys = sort map "$_", keys %$x;
30 0 my @ykeys = sort map "$_", keys %$y;
31 0 ▶ return false unless @xkeys == @ykeys;
Branch: 1 branch
BranchTrueFalseTotal
unless @xkeys == @ykeys 0 0 0
32 0 my @xvals = map $x->{$_}, @xkeys;
33 0 my @yvals = map $y->{$_}, @ykeys;
34 0 ▶ for (my $i = 0; $i < @xkeys; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @xkeys) 0 0 0
35 0 ▶ return false unless "$xkeys[$i]" eq "$ykeys[$i]";
Branch: 1 branch
BranchTrueFalseTotal
unless "$xkeys[$i]" eq "$ykeys[$i]" 0 0 0
36 0 my $bool = equiv($xvals[$i], $yvals[$i]);
37 0 ▶ return false if "$bool" eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if "$bool" eq 0 0 0 0
38 }
39 0 return true;
40 }
41 0 BOOLEAN->new($$x eq $$y);
42 }
43  
44 0 ▶sub gt { $_[0] > $_[1] }
Subroutine gt: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 0 ▶sub gte { $_[0] >= $_[1] }
Subroutine gte: not called CC=1 SCAR=6.9
Pod undocumented
47  
48 0 ▶sub isPos { $_[0] > 0 }
Subroutine isPos: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 0 ▶sub isZero { ${$_[0]} == 0 }
Subroutine isZero: not called CC=1 SCAR=6.9
Pod undocumented
51  
52 0 ▶sub lt { $_[0] < $_[1] }
Subroutine lt: not called CC=1 SCAR=6.9
Pod undocumented
53  
54 0 ▶sub lte { $_[0] <= $_[1] }
Subroutine lte: not called CC=1 SCAR=6.9
Pod undocumented
55  
56 0 ▶sub minus { $_[0] - $_[1] }
Subroutine minus: not called CC=1 SCAR=6.9
Pod undocumented
57  
58 0 ▶sub multiply { $_[0] * $_[1] }
Subroutine multiply: not called CC=1 SCAR=6.9
Pod undocumented
59  
60 sub range {
61 0 ▶ my ($start, $end, $step) = @_;
Subroutine range: not called CC=9 SCAR=45.0
Pod undocumented
62 0 ▶ if (not defined $end) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $end) 0 0 0
63 0 $end = $start;
64 0 $start = NUMBER->new(0);
65 }
66 0 ▶ $step //= NUMBER->new(1);
Condition0%0/3
$step //= "Lingy::Lang::Number"->new(1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$step //= "Lingy::Lang::Number"->new(1)
$step "Lingy::Lang::Number"->new(1)
Truth table0%0/3
A //= B
A= $stepB= "Lingy::Lang::Number"->new(1)
ABresult
1X1
011
000
67 0 ($start, $end, $step) = ($$start, $$end, $$step);
68 0 ▶ return list([]) if $step == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $step == 0 0 0 0
69 0 my @range;
70 0 ▶ if ($step > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($step > 0) { } 0 0 0
71 0 ▶ return list([]) if $start > $end;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $end 0 0 0
72 0 ▶ while ($start < $end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start < $end) 0 0 0
73 0 push @range, NUMBER->new($start);
74 0 $start += $step;
75 }
76 } else {
77 0 ▶ return list([]) if $start < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $start < $end 0 0 0
78 0 ▶ while ($start > $end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start > $end) 0 0 0
79 0 push @range, NUMBER->new($start);
80 0 $start += $step;
81 }
82 }
83 0 list([@range]);
84 }
85  
86 sub remainder {
87 0 ▶ $_[0] % $_[1];
Subroutine remainder: not called CC=1 SCAR=6.9
Pod undocumented
88 }
89  
90 1 1;
« lib/Lingy/Lang/Fn.pm ↑ Summary lib/Lingy/Reader.pm »