line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Types::MooseLike::Numeric; |
2
|
1
|
|
|
1
|
|
10981
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
414
|
use MooX::Types::MooseLike qw(exception_message); |
|
1
|
|
|
|
|
1269
|
|
|
1
|
|
|
|
|
42
|
|
5
|
1
|
|
|
1
|
|
475
|
use MooX::Types::MooseLike::Base; |
|
1
|
|
|
|
|
2819
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
5
|
use Exporter 5.57 'import'; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
344
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $type_definitions = [ |
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
name => 'PositiveNum', |
14
|
|
|
|
|
|
|
subtype_of => 'Num', |
15
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
16
|
|
|
|
|
|
|
test => sub { $_[0] > 0 }, |
17
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a positive number') }, |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
name => 'PositiveOrZeroNum', |
21
|
|
|
|
|
|
|
subtype_of => 'Num', |
22
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
23
|
|
|
|
|
|
|
test => sub { $_[0] >= 0 }, |
24
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a positive number or zero') }, |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
name => 'PositiveInt', |
28
|
|
|
|
|
|
|
subtype_of => 'Int', |
29
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
30
|
|
|
|
|
|
|
test => sub { $_[0] > 0 }, |
31
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a positive integer') }, |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
name => 'PositiveOrZeroInt', |
35
|
|
|
|
|
|
|
subtype_of => 'Int', |
36
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
37
|
|
|
|
|
|
|
test => sub { $_[0] >= 0 }, |
38
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a positive integer or zero') }, |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
name => 'NegativeNum', |
42
|
|
|
|
|
|
|
subtype_of => 'Num', |
43
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
44
|
|
|
|
|
|
|
test => sub { $_[0] < 0 }, |
45
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a negative number') }, |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
name => 'NegativeOrZeroNum', |
49
|
|
|
|
|
|
|
subtype_of => 'Num', |
50
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
51
|
|
|
|
|
|
|
test => sub { $_[0] <= 0 }, |
52
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a negative number or zero') }, |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
name => 'NegativeInt', |
56
|
|
|
|
|
|
|
subtype_of => 'Int', |
57
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
58
|
|
|
|
|
|
|
test => sub { $_[0] < 0 }, |
59
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a negative integer') }, |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
name => 'NegativeOrZeroInt', |
63
|
|
|
|
|
|
|
subtype_of => 'Int', |
64
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Base', |
65
|
|
|
|
|
|
|
test => sub { $_[0] <= 0 }, |
66
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a negative integer or zero') }, |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
name => 'SingleDigit', |
70
|
|
|
|
|
|
|
subtype_of => 'PositiveOrZeroInt', |
71
|
|
|
|
|
|
|
from => 'MooX::Types::MooseLike::Numeric', |
72
|
|
|
|
|
|
|
test => sub { $_[0] < 10 }, |
73
|
|
|
|
|
|
|
message => sub { return exception_message($_[0], 'a single digit') }, |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
]; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
MooX::Types::MooseLike::register_types($type_definitions, __PACKAGE__, |
78
|
|
|
|
|
|
|
'MooseX::Types::Common::Numeric'); |
79
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('all' => \@EXPORT_OK); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |