| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mo::utils::Number::Alias; |
|
2
|
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
537204
|
use base qw(Exporter); |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
2703
|
|
|
4
|
10
|
|
|
10
|
|
77
|
use strict; |
|
|
10
|
|
|
|
|
28
|
|
|
|
10
|
|
|
|
|
489
|
|
|
5
|
10
|
|
|
10
|
|
68
|
use warnings; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
873
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
9771
|
use Mo::utils::Number::Range 0.03 qw(check_int_range check_natural_range); |
|
|
10
|
|
|
|
|
304
|
|
|
|
10
|
|
|
|
|
359
|
|
|
8
|
10
|
|
|
10
|
|
995
|
use Readonly; |
|
|
10
|
|
|
|
|
24
|
|
|
|
10
|
|
|
|
|
4314
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw( |
|
11
|
|
|
|
|
|
|
check_int8 check_int16 check_int32 check_int64 |
|
12
|
|
|
|
|
|
|
check_uint8 check_uint16 check_uint32 check_uint64 |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.10; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub check_int8 { |
|
18
|
9
|
|
|
9
|
1
|
397719
|
my ($self, $key) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
9
|
|
|
|
|
38
|
return check_int_range($self, $key, -128, 127); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub check_int16 { |
|
24
|
9
|
|
|
9
|
1
|
367876
|
my ($self, $key) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
9
|
|
|
|
|
39
|
return check_int_range($self, $key, -32768, 32767); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub check_int32 { |
|
30
|
9
|
|
|
9
|
1
|
373686
|
my ($self, $key) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
9
|
|
|
|
|
39
|
return check_int_range($self, $key, -2147483648, 2147483647); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub check_int64 { |
|
36
|
9
|
|
|
9
|
1
|
344406
|
my ($self, $key) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
9
|
|
|
|
|
38
|
return check_int_range($self, $key, -9223372036854775808, 9223372036854775807); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub check_uint8 { |
|
42
|
9
|
|
|
9
|
1
|
476151
|
my ($self, $key) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
9
|
|
|
|
|
39
|
return check_natural_range($self, $key, 0, 255); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub check_uint16 { |
|
48
|
9
|
|
|
9
|
1
|
399199
|
my ($self, $key) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
34
|
return check_natural_range($self, $key, 0, 65535); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub check_uint32 { |
|
54
|
9
|
|
|
9
|
1
|
366789
|
my ($self, $key) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
9
|
|
|
|
|
38
|
return check_natural_range($self, $key, 0, 4294967295); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub check_uint64 { |
|
60
|
9
|
|
|
9
|
1
|
401190
|
my ($self, $key) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
84
|
return check_natural_range($self, $key, 0, 18446744073709551615); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=encoding utf8 |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Mo::utils::Number::Alias - Mo number utilities, aliases. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw( |
|
80
|
|
|
|
|
|
|
check_int8 check_int16 check_int32 check_int64 |
|
81
|
|
|
|
|
|
|
check_uint8 check_uint16 check_uint32 check_uint64 |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
check_int8($self, $key); |
|
85
|
|
|
|
|
|
|
check_int16($self, $key); |
|
86
|
|
|
|
|
|
|
check_int32($self, $key); |
|
87
|
|
|
|
|
|
|
check_int64($self, $key); |
|
88
|
|
|
|
|
|
|
check_uint8($self, $key); |
|
89
|
|
|
|
|
|
|
check_uint16($self, $key); |
|
90
|
|
|
|
|
|
|
check_uint32($self, $key); |
|
91
|
|
|
|
|
|
|
check_uint64($self, $key); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Mo number aliases utilities for checking of data objects. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C<check_int8> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
check_int8($self, $key); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of integer numbers (-128, ... -2, -1, 0, 1, 2, ..., 127). |
|
106
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns undef. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 C<check_int16> |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
check_int16($self, $key); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of integer numbers (-32768, ... -2, -1, 0, 1, 2, ..., 32767). |
|
117
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns undef. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 C<check_int32> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
check_int32($self, $key); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of integer numbers (-2147483648, ... -2, -1, 0, 1, 2, ..., 2147483647). |
|
128
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns undef. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 C<check_int64> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
check_int64($self, $key); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of integer numbers (-9223372036854775808, ... -2, -1, 0, 1, 2, ..., 9223372036854775807). |
|
139
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns undef. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 C<check_uint8> |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
check_uint8($self, $key); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of natural numbers (0, 1, 2, ..., 255). |
|
150
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Returns undef. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 C<check_uint16> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
check_uint16($self, $key); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of natural numbers (0, 1, 2, ..., 65535). |
|
161
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns undef. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 C<check_uint32> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
check_uint32($self, $key); |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of natural numbers (0, 1, 2, ..., 4294967295). |
|
172
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Returns undef. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 C<check_uint64> |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
check_uint64($self, $key); |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
I<Since version 0.09.> |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's in range of natural numbers (0, 1, 2, ..., 18446744073709551615). |
|
183
|
|
|
|
|
|
|
Value could be undefined or doesn't exist. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns undef. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 ERRORS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
check_int8(): |
|
190
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_int_range(): |
|
191
|
|
|
|
|
|
|
Parameter '%s' must be a integer. |
|
192
|
|
|
|
|
|
|
Value: %s |
|
193
|
|
|
|
|
|
|
Parameter '%s' must be a integer between -128 and 127. |
|
194
|
|
|
|
|
|
|
Value: %s |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
check_int16(): |
|
197
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_int_range(): |
|
198
|
|
|
|
|
|
|
Parameter '%s' must be a integer. |
|
199
|
|
|
|
|
|
|
Value: %s |
|
200
|
|
|
|
|
|
|
Parameter '%s' must be a integer between -32768 and 32767. |
|
201
|
|
|
|
|
|
|
Value: %s |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
check_int32(): |
|
204
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_int_range(): |
|
205
|
|
|
|
|
|
|
Parameter '%s' must be a integer. |
|
206
|
|
|
|
|
|
|
Value: %s |
|
207
|
|
|
|
|
|
|
Parameter '%s' must be a integer between -2147483648 and 2147483647. |
|
208
|
|
|
|
|
|
|
Value: %s |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
check_int64(): |
|
211
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_int_range(): |
|
212
|
|
|
|
|
|
|
Parameter '%s' must be a integer. |
|
213
|
|
|
|
|
|
|
Value: %s |
|
214
|
|
|
|
|
|
|
Parameter '%s' must be a integer between -9223372036854775808 and 9223372036854775807. |
|
215
|
|
|
|
|
|
|
Value: %s |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
check_uint8(): |
|
218
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_natural_range(): |
|
219
|
|
|
|
|
|
|
Parameter '%s' must be a natural number. |
|
220
|
|
|
|
|
|
|
Value: %s |
|
221
|
|
|
|
|
|
|
Parameter '%s' must be a natural number between 0 and 255. |
|
222
|
|
|
|
|
|
|
Value: %s |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
check_uint16(): |
|
225
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_natural_range(): |
|
226
|
|
|
|
|
|
|
Parameter '%s' must be a natural number. |
|
227
|
|
|
|
|
|
|
Value: %s |
|
228
|
|
|
|
|
|
|
Parameter '%s' must be a natural number between 0 and 65535. |
|
229
|
|
|
|
|
|
|
Value: %s |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
check_uint32(): |
|
232
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_natural_range(): |
|
233
|
|
|
|
|
|
|
Parameter '%s' must be a natural number. |
|
234
|
|
|
|
|
|
|
Value: %s |
|
235
|
|
|
|
|
|
|
Parameter '%s' must be a natural number between 0 and 4294967295. |
|
236
|
|
|
|
|
|
|
Value: %s |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
check_uint64(): |
|
239
|
|
|
|
|
|
|
From Mo::utils::Number::Range::check_natural_range(): |
|
240
|
|
|
|
|
|
|
Parameter '%s' must be a natural number. |
|
241
|
|
|
|
|
|
|
Value: %s |
|
242
|
|
|
|
|
|
|
Parameter '%s' must be a natural number between 0 and 18446744073709551615. |
|
243
|
|
|
|
|
|
|
Value: %s |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=for comment filename=check_int8_ok.pl |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
use strict; |
|
250
|
|
|
|
|
|
|
use warnings; |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int8); |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
my $self = { |
|
255
|
|
|
|
|
|
|
'key' => -2, |
|
256
|
|
|
|
|
|
|
}; |
|
257
|
|
|
|
|
|
|
check_int8($self, 'key'); |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Print out. |
|
260
|
|
|
|
|
|
|
print "ok\n"; |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# Output: |
|
263
|
|
|
|
|
|
|
# ok |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=for comment filename=check_int8_fail.pl |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
use strict; |
|
270
|
|
|
|
|
|
|
use warnings; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
use Error::Pure; |
|
273
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int8); |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
my $self = { |
|
278
|
|
|
|
|
|
|
'key' => -300, |
|
279
|
|
|
|
|
|
|
}; |
|
280
|
|
|
|
|
|
|
check_int8($self, 'key'); |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# Print out. |
|
283
|
|
|
|
|
|
|
print "ok\n"; |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# Output like: |
|
286
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a integer between -128 and 127. |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head1 EXAMPLE3 |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=for comment filename=check_int16_ok.pl |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
use strict; |
|
293
|
|
|
|
|
|
|
use warnings; |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int16); |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
my $self = { |
|
298
|
|
|
|
|
|
|
'key' => -2, |
|
299
|
|
|
|
|
|
|
}; |
|
300
|
|
|
|
|
|
|
check_int16($self, 'key'); |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# Print out. |
|
303
|
|
|
|
|
|
|
print "ok\n"; |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# Output: |
|
306
|
|
|
|
|
|
|
# ok |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head1 EXAMPLE4 |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=for comment filename=check_int16_fail.pl |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
use strict; |
|
313
|
|
|
|
|
|
|
use warnings; |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
use Error::Pure; |
|
316
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int16); |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
my $self = { |
|
321
|
|
|
|
|
|
|
'key' => -300000, |
|
322
|
|
|
|
|
|
|
}; |
|
323
|
|
|
|
|
|
|
check_int16($self, 'key'); |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# Print out. |
|
326
|
|
|
|
|
|
|
print "ok\n"; |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# Output like: |
|
329
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a integer between -32768 and 32767. |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=head1 EXAMPLE5 |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=for comment filename=check_int32_ok.pl |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
use strict; |
|
336
|
|
|
|
|
|
|
use warnings; |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int32); |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
my $self = { |
|
341
|
|
|
|
|
|
|
'key' => -2, |
|
342
|
|
|
|
|
|
|
}; |
|
343
|
|
|
|
|
|
|
check_int32($self, 'key'); |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
# Print out. |
|
346
|
|
|
|
|
|
|
print "ok\n"; |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# Output: |
|
349
|
|
|
|
|
|
|
# ok |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=head1 EXAMPLE6 |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=for comment filename=check_int32_fail.pl |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
use strict; |
|
356
|
|
|
|
|
|
|
use warnings; |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
use Error::Pure; |
|
359
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int32); |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
my $self = { |
|
364
|
|
|
|
|
|
|
'key' => -30000000000, |
|
365
|
|
|
|
|
|
|
}; |
|
366
|
|
|
|
|
|
|
check_int32($self, 'key'); |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
# Print out. |
|
369
|
|
|
|
|
|
|
print "ok\n"; |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
# Output like: |
|
372
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a integer between -2147483648 and 2147483647. |
|
373
|
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=head1 EXAMPLE7 |
|
375
|
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=for comment filename=check_int64_ok.pl |
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
use strict; |
|
379
|
|
|
|
|
|
|
use warnings; |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int64); |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
my $self = { |
|
384
|
|
|
|
|
|
|
'key' => -2, |
|
385
|
|
|
|
|
|
|
}; |
|
386
|
|
|
|
|
|
|
check_int64($self, 'key'); |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
# Print out. |
|
389
|
|
|
|
|
|
|
print "ok\n"; |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# Output: |
|
392
|
|
|
|
|
|
|
# ok |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head1 EXAMPLE8 |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=for comment filename=check_int64_fail.pl |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
use strict; |
|
399
|
|
|
|
|
|
|
use warnings; |
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
use Error::Pure; |
|
402
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_int64); |
|
403
|
|
|
|
|
|
|
use Math::BigInt; |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
my $self = { |
|
408
|
|
|
|
|
|
|
'key' => Math::BigInt->new(-30000000000000000000), |
|
409
|
|
|
|
|
|
|
}; |
|
410
|
|
|
|
|
|
|
check_int64($self, 'key'); |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
# Print out. |
|
413
|
|
|
|
|
|
|
print "ok\n"; |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# Output like: |
|
416
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a integer between -9223372036854775808 and 9223372036854775807. |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=head1 EXAMPLE9 |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=for comment filename=check_uint8_ok.pl |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
use strict; |
|
423
|
|
|
|
|
|
|
use warnings; |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint8); |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
my $self = { |
|
428
|
|
|
|
|
|
|
'key' => 2, |
|
429
|
|
|
|
|
|
|
}; |
|
430
|
|
|
|
|
|
|
check_uint8($self, 'key'); |
|
431
|
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
# Print out. |
|
433
|
|
|
|
|
|
|
print "ok\n"; |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
# Output: |
|
436
|
|
|
|
|
|
|
# ok |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=head1 EXAMPLE10 |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=for comment filename=check_uint8_fail.pl |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
use strict; |
|
443
|
|
|
|
|
|
|
use warnings; |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
use Error::Pure; |
|
446
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint8); |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
my $self = { |
|
451
|
|
|
|
|
|
|
'key' => 300, |
|
452
|
|
|
|
|
|
|
}; |
|
453
|
|
|
|
|
|
|
check_uint8($self, 'key'); |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
# Print out. |
|
456
|
|
|
|
|
|
|
print "ok\n"; |
|
457
|
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
# Output like: |
|
459
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a natural number between 0 and 255. |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=head1 EXAMPLE11 |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=for comment filename=check_uint16_ok.pl |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
use strict; |
|
466
|
|
|
|
|
|
|
use warnings; |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint16); |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
my $self = { |
|
471
|
|
|
|
|
|
|
'key' => 60000, |
|
472
|
|
|
|
|
|
|
}; |
|
473
|
|
|
|
|
|
|
check_uint16($self, 'key'); |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
# Print out. |
|
476
|
|
|
|
|
|
|
print "ok\n"; |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
# Output: |
|
479
|
|
|
|
|
|
|
# ok |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=head1 EXAMPLE12 |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=for comment filename=check_uint16_fail.pl |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
use strict; |
|
486
|
|
|
|
|
|
|
use warnings; |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
use Error::Pure; |
|
489
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint16); |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
my $self = { |
|
494
|
|
|
|
|
|
|
'key' => 300000, |
|
495
|
|
|
|
|
|
|
}; |
|
496
|
|
|
|
|
|
|
check_uint16($self, 'key'); |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
# Print out. |
|
499
|
|
|
|
|
|
|
print "ok\n"; |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
# Output like: |
|
502
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a natural number between 0 and 65535. |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=head1 EXAMPLE13 |
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
=for comment filename=check_uint32_ok.pl |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
use strict; |
|
509
|
|
|
|
|
|
|
use warnings; |
|
510
|
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint32); |
|
512
|
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
my $self = { |
|
514
|
|
|
|
|
|
|
'key' => 3000000000, |
|
515
|
|
|
|
|
|
|
}; |
|
516
|
|
|
|
|
|
|
check_uint32($self, 'key'); |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
# Print out. |
|
519
|
|
|
|
|
|
|
print "ok\n"; |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
# Output: |
|
522
|
|
|
|
|
|
|
# ok |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=head1 EXAMPLE14 |
|
525
|
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
=for comment filename=check_uint32_fail.pl |
|
527
|
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
use strict; |
|
529
|
|
|
|
|
|
|
use warnings; |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
use Error::Pure; |
|
532
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint32); |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
my $self = { |
|
537
|
|
|
|
|
|
|
'key' => 300000000000, |
|
538
|
|
|
|
|
|
|
}; |
|
539
|
|
|
|
|
|
|
check_uint32($self, 'key'); |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
# Print out. |
|
542
|
|
|
|
|
|
|
print "ok\n"; |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
# Output like: |
|
545
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a natural number between 0 and 4294967295. |
|
546
|
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=head1 EXAMPLE15 |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=for comment filename=check_uint64_ok.pl |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
use strict; |
|
552
|
|
|
|
|
|
|
use warnings; |
|
553
|
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint64); |
|
555
|
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
my $self = { |
|
557
|
|
|
|
|
|
|
'key' => 200000000000, |
|
558
|
|
|
|
|
|
|
}; |
|
559
|
|
|
|
|
|
|
check_uint64($self, 'key'); |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
# Print out. |
|
562
|
|
|
|
|
|
|
print "ok\n"; |
|
563
|
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
# Output: |
|
565
|
|
|
|
|
|
|
# ok |
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=head1 EXAMPLE16 |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=for comment filename=check_uint64_fail.pl |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
use strict; |
|
572
|
|
|
|
|
|
|
use warnings; |
|
573
|
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
use Error::Pure; |
|
575
|
|
|
|
|
|
|
use Mo::utils::Number::Alias qw(check_uint64); |
|
576
|
|
|
|
|
|
|
use Math::BigInt; |
|
577
|
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
my $self = { |
|
581
|
|
|
|
|
|
|
'key' => Math::BigInt->new(30000000000000000000), |
|
582
|
|
|
|
|
|
|
}; |
|
583
|
|
|
|
|
|
|
check_uint64($self, 'key'); |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
# Print out. |
|
586
|
|
|
|
|
|
|
print "ok\n"; |
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
# Output like: |
|
589
|
|
|
|
|
|
|
# #Error [...Range.pm:?] Parameter 'key' must be a natural number between 0 and 18446744073709551615. |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
592
|
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
L<Exporter>, |
|
594
|
|
|
|
|
|
|
L<Mo::utils::Number::Range>, |
|
595
|
|
|
|
|
|
|
L<Readonly>. |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=over |
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=item L<Mo::utils::Number> |
|
602
|
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
Mo number utilities. |
|
604
|
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=item L<Mo> |
|
606
|
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
Micro Objects. Mo is less. |
|
608
|
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item L<Mo::utils> |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Mo utilities. |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=back |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
616
|
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Mo-utils-Number> |
|
618
|
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=head1 AUTHOR |
|
620
|
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
622
|
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
L<http://skim.cz> |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
© 2024-2026 Michal Josef Špaček |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
BSD 2-Clause License |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
=head1 VERSION |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
0.10 |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
=cut |