line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Number Object for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Number; |
3
|
|
|
|
|
|
|
|
4
|
145
|
|
|
145
|
|
36879
|
use 5.010; |
|
145
|
|
|
|
|
420
|
|
5
|
|
|
|
|
|
|
|
6
|
145
|
|
|
145
|
|
775
|
use Scalar::Util 'blessed', 'looks_like_number'; |
|
145
|
|
|
|
|
231
|
|
|
145
|
|
|
|
|
11778
|
|
7
|
145
|
|
|
145
|
|
20490
|
use Data::Object 'deduce_deep', 'detract_deep', 'throw'; |
|
145
|
|
|
|
|
245
|
|
|
145
|
|
|
|
|
9654
|
|
8
|
145
|
|
|
145
|
|
19944
|
use Data::Object::Class 'with'; |
|
145
|
|
|
|
|
355
|
|
|
145
|
|
|
|
|
1663
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Data::Object::Role::Number'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload ( |
13
|
145
|
|
|
|
|
1266
|
'bool' => 'data', |
14
|
|
|
|
|
|
|
'""' => 'data', |
15
|
|
|
|
|
|
|
'~~' => 'data', |
16
|
|
|
|
|
|
|
fallback => 1, |
17
|
145
|
|
|
145
|
|
95469
|
); |
|
145
|
|
|
|
|
254
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.41'; # VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
627
|
|
|
627
|
0
|
86429
|
my $class = shift; |
23
|
627
|
|
|
|
|
913
|
my $args = shift; |
24
|
627
|
|
|
|
|
745
|
my $role = 'Data::Object::Role::Type'; |
25
|
|
|
|
|
|
|
|
26
|
627
|
0
|
33
|
|
|
2619
|
$args = $args->data if blessed($args) |
|
|
|
33
|
|
|
|
|
27
|
|
|
|
|
|
|
and $args->can('does') |
28
|
|
|
|
|
|
|
and $args->does($role); |
29
|
|
|
|
|
|
|
|
30
|
627
|
|
|
|
|
1011
|
$args =~ s/^\+//; # not keen on this but ... |
31
|
|
|
|
|
|
|
|
32
|
627
|
50
|
33
|
|
|
5077
|
throw 'Type Instantiation Error: Not a Number' |
|
|
|
33
|
|
|
|
|
33
|
|
|
|
|
|
|
unless defined($args) && !ref($args) |
34
|
|
|
|
|
|
|
&& looks_like_number($args); |
35
|
|
|
|
|
|
|
|
36
|
627
|
|
|
|
|
3163
|
return bless \$args, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
around 'abs' => sub { |
40
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
41
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
42
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
around 'atan2' => sub { |
46
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
47
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
48
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
around 'cos' => sub { |
52
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
53
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
54
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub data { |
58
|
711
|
|
|
711
|
0
|
216736
|
goto &detract; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub detract { |
62
|
713
|
|
|
713
|
0
|
2395
|
return detract_deep shift; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
around 'decr' => sub { |
66
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
67
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
68
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
around 'downto' => sub { |
72
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
73
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
74
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
around 'eq' => sub { |
78
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
79
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
80
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
around 'exp' => sub { |
84
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
85
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
86
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
around 'gt' => sub { |
90
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
91
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
92
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
around 'gte' => sub { |
96
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
97
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
98
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
99
|
|
|
|
|
|
|
}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
around 'hex' => sub { |
102
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
103
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
104
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
around 'incr' => sub { |
108
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
109
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
110
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
around 'int' => sub { |
114
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
115
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
116
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
around 'lt' => sub { |
120
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
121
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
122
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
123
|
|
|
|
|
|
|
}; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
around 'lte' => sub { |
126
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
127
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
128
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
129
|
|
|
|
|
|
|
}; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
around 'log' => sub { |
132
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
133
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
134
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
around 'mod' => sub { |
138
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
139
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
140
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
141
|
|
|
|
|
|
|
}; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
around 'ne' => sub { |
144
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
145
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
146
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
147
|
|
|
|
|
|
|
}; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
around 'neg' => sub { |
150
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
151
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
152
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
153
|
|
|
|
|
|
|
}; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
around 'pow' => sub { |
156
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
157
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
158
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
159
|
|
|
|
|
|
|
}; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
around 'sin' => sub { |
162
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
163
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
164
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
165
|
|
|
|
|
|
|
}; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
around 'sqrt' => sub { |
168
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
169
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
170
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
171
|
|
|
|
|
|
|
}; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
around 'to' => sub { |
174
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
175
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
176
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
177
|
|
|
|
|
|
|
}; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
around 'upto' => sub { |
180
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
181
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
182
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
183
|
|
|
|
|
|
|
}; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |