| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Declare::Constraints::Simple::Library::Numerical - Numerical Constraints |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=cut |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Declare::Constraints::Simple::Library::Numerical; |
|
8
|
12
|
|
|
12
|
|
141
|
use warnings; |
|
|
12
|
|
|
|
|
96
|
|
|
|
12
|
|
|
|
|
427
|
|
|
9
|
12
|
|
|
12
|
|
62
|
use strict; |
|
|
12
|
|
|
|
|
26
|
|
|
|
12
|
|
|
|
|
555
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
12
|
|
|
12
|
|
137
|
use Declare::Constraints::Simple-Library; |
|
|
12
|
|
|
|
|
23
|
|
|
|
12
|
|
|
|
|
236
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
12
|
|
|
12
|
|
85
|
use Scalar::Util (); |
|
|
12
|
|
|
|
|
53
|
|
|
|
12
|
|
|
|
|
2842
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# test for number-conformity |
|
18
|
|
|
|
|
|
|
my $looks_like_number = IsNumber; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# only integers |
|
21
|
|
|
|
|
|
|
my $is_int = IsInt; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTIONS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This library contains the constraints needed to validate numerical values. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 CONSTRAINTS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 IsNumber() |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
True if the value is a number according to Ls |
|
32
|
|
|
|
|
|
|
C. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
constraint 'IsNumber', |
|
37
|
|
|
|
|
|
|
sub { |
|
38
|
|
|
|
|
|
|
return sub { |
|
39
|
|
|
|
|
|
|
return _false('Undefined Value') unless defined $_[0]; |
|
40
|
|
|
|
|
|
|
return _result(Scalar::Util::looks_like_number($_[0]), |
|
41
|
|
|
|
|
|
|
'Does not look like Number'); |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 IsInt() |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
True if the value is an integer. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
constraint 'IsInt', |
|
52
|
|
|
|
|
|
|
sub { |
|
53
|
|
|
|
|
|
|
return sub { |
|
54
|
|
|
|
|
|
|
return _false('Undefined Value') unless defined $_[0]; |
|
55
|
|
|
|
|
|
|
return _result(scalar($_[0] =~ /^-?\d+$/), 'Not an Integer'); |
|
56
|
|
|
|
|
|
|
}; |
|
57
|
|
|
|
|
|
|
}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
L, L |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Robert 'phaylon' Sedlacek Cphaylon@dunkelheit.atE> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This module is free software, you can redistribute it and/or modify it |
|
70
|
|
|
|
|
|
|
under the same terms as perl itself. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |