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