| 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
Condition0%0/6
$x->isa("Lingy::Lang::ListClass") and $y->isa("Lingy::Lang::ListClass") or ref $x eq ref $y
$x->isa("Lingy::Lang::ListClass") and $y->isa("Lingy::Lang::ListClass")
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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return false unless @$x == @$y; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | for (my $i = 0; $i < @$x; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $bool = equiv($x->[$i], $y->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return false if "$bool" eq '0'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | return true; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($x->isa(HASHMAP)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return false unless "$xkeys[$i]" eq "$ykeys[$i]"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $bool = equiv($xvals[$i], $yvals[$i]); | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return false if "$bool" eq '0'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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)
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)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ($start, $end, $step) = ($$start, $$end, $$step); | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return list([]) if $step == 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my @range; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($step > 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return list([]) if $start > $end; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | while ($start < $end) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | push @range, NUMBER->new($start); | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $start += $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return list([]) if $start < $end; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | while ($start > $end) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||||||