lib/Lingy/Number.pm

filter: Statementstmt 93.7% 60 / 64 Branchbran 55.0% 22 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.1% 16 / 17 Podpod 0.0% 0 / 11 totaltotal 74.2% 98 / 132 CC 21 SCAR 12.3
CC
21
Cov
79%
equal_to
12.0
greater_equal
3.1
less_than
3.1
CRAP 3.4
« lib/Lingy/Numbers.pm ↑ Summary lib/Lingy/Boolean.pm »
1 53 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Lingy::Number;
3  
4 53 ▶use Lingy::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 53 ▶use base 'Lingy::ScalarClass';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 use overload
8 1079 ▶ '""' => sub { 0 + ${$_[0]} },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
9 53 '+' => \&add,
10 '-' => \&subtract,
11 '*' => \&multiply,
12 '/' => \&divide,
13 '==' => \&equal_to,
14 '>' => \&greater_than,
15 '>=' => \&greater_equal,
16 '<' => \&less_than,
17 '<=' => \&less_equal,
18 '%' => \&modulo,
19 cmp => \&comp_pair,
20 53 ;
21  
22 2 ▶sub cast {
Subroutine cast: called CC=1 SCAR=0.0
Pod undocumented
23 2 $_[1];
24 }
25  
26 0 ▶sub equal_to {
Subroutine equal_to: not called CC=3 SCAR=24.8
Pod undocumented
27 0 my ($x, $y) = @_;
28 0 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 0 0 0
29 0 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 0 0 0
30 0 BOOLEAN->new($x == $y);
31 }
32  
33 677 ▶sub greater_than {
Subroutine greater_than: called CC=3 SCAR=11.0
Pod undocumented
34 677 my ($x, $y) = @_;
35 677 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 677 0 677
36 677 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 427 250 677
37 677 BOOLEAN->new($x > $y);
38 }
39  
40 248 ▶sub greater_equal {
Subroutine greater_equal: called CC=3 SCAR=11.4
Pod undocumented
41 248 my ($x, $y) = @_;
42 248 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 248 0 248
43 248 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 248 0 248
44 248 BOOLEAN->new($x >= $y);
45 }
46  
47 247 ▶sub less_than {
Subroutine less_than: called CC=3 SCAR=11.4
Pod undocumented
48 247 my ($x, $y) = @_;
49 247 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 247 0 247
50 247 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 247 0 247
51 247 BOOLEAN->new($x < $y);
52 }
53  
54 23 ▶sub less_equal {
Subroutine less_equal: called CC=3 SCAR=11.4
Pod undocumented
55 23 my ($x, $y) = @_;
56 23 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 23 0 23
57 23 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 23 0 23
58 23 BOOLEAN->new($x <= $y);
59 }
60  
61 10151 ▶sub add {
Subroutine add: called CC=3 SCAR=11.0
Pod undocumented
62 10151 my ($x, $y) = @_;
63 10151 my $class = ref($x);
64 10151 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 10151 0 10151
65 10151 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 10131 20 10151
66 10151 $class->new($x + $y);
67 }
68  
69 20075 ▶sub subtract {
Subroutine subtract: called CC=3 SCAR=11.0
Pod undocumented
70 20075 my ($x, $y) = @_;
71 20075 my $class = ref($x);
72 20075 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 20075 0 20075
73 20075 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 20060 15 20075
74 20075 $class->new($x - $y);
75 }
76  
77 25 ▶sub multiply {
Subroutine multiply: called CC=3 SCAR=11.0
Pod undocumented
78 25 my ($x, $y) = @_;
79 25 my $class = ref($x);
80 25 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 25 0 25
81 25 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 24 1 25
82 25 $class->new($x * $y);
83 }
84  
85 27 ▶sub divide {
Subroutine divide: called CC=3 SCAR=11.3
Pod undocumented
86 27 my ($x, $y) = @_;
87 27 my $class = ref($x);
88 27 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 27 0 27
89 27 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 27 0 27
90 27 $class->new($x / $y);
91 }
92  
93 134 ▶sub modulo {
Subroutine modulo: called CC=3 SCAR=11.3
Pod undocumented
94 134 my ($x, $y) = @_;
95 134 my $class = ref($x);
96 134 ▶ $x = ref($x) ? $$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
ref $x ? : 134 0 134
97 134 ▶ $y = ref($y) ? $$y : $y;
Branch: 1 branch
BranchTrueFalseTotal
ref $y ? : 134 0 134
98 134 $class->new($x % $y);
99 }
100  
101 53 1;
« lib/Lingy/Numbers.pm ↑ Summary lib/Lingy/Boolean.pm »