File Coverage

blib/lib/Specio/Library/Numeric.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Specio::Library::Numeric;
2              
3 12     12   689 use strict;
  12         24  
  12         378  
4 12     12   69 use warnings;
  12         23  
  12         538  
5              
6             our $VERSION = '0.47';
7              
8 12     12   69 use parent 'Specio::Exporter';
  12         38  
  12         96  
9              
10 12     12   869 use Specio::Declare;
  12         25  
  12         100  
11 12     12   81 use Specio::Library::Builtins;
  12         25  
  12         89  
12              
13             declare(
14             'PositiveNum',
15             parent => t('Num'),
16             inline => sub {
17             return
18             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
19             (
20             %s
21             &&
22             %s > 0
23             )
24             EOF
25             },
26             );
27              
28             declare(
29             'PositiveOrZeroNum',
30             parent => t('Num'),
31             inline => sub {
32             return
33             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
34             (
35             %s
36             &&
37             %s >= 0
38             )
39             EOF
40             },
41             );
42              
43             declare(
44             'PositiveInt',
45             parent => t('Int'),
46             inline => sub {
47             return
48             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
49             (
50             %s
51             &&
52             %s > 0
53             )
54             EOF
55             },
56             );
57              
58             declare(
59             'PositiveOrZeroInt',
60             parent => t('Int'),
61             inline => sub {
62             return
63             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
64             (
65             %s
66             &&
67             %s >= 0
68             )
69             EOF
70             },
71             );
72              
73             declare(
74             'NegativeNum',
75             parent => t('Num'),
76             inline => sub {
77             return
78             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
79             (
80             %s
81             &&
82             %s < 0
83             )
84             EOF
85             },
86             );
87              
88             declare(
89             'NegativeOrZeroNum',
90             parent => t('Num'),
91             inline => sub {
92             return
93             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
94             (
95             %s
96             &&
97             %s <= 0
98             )
99             EOF
100             },
101             );
102              
103             declare(
104             'NegativeInt',
105             parent => t('Int'),
106             inline => sub {
107             return
108             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
109             (
110             %s
111             &&
112             %s < 0
113             )
114             EOF
115             },
116             );
117              
118             declare(
119             'NegativeOrZeroInt',
120             parent => t('Int'),
121             inline => sub {
122             return
123             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
124             (
125             %s
126             &&
127             %s <= 0
128             )
129             EOF
130             },
131             );
132              
133             declare(
134             'SingleDigit',
135             parent => t('Int'),
136             inline => sub {
137             return
138             sprintf(
139             <<'EOF', $_[0]->parent->inline_check( $_[1] ), ( $_[1] ) x 2 );
140             (
141             %s
142             &&
143             %s >= -9
144             &&
145             %s <= 9
146             )
147             EOF
148             },
149             );
150              
151             1;
152              
153             # ABSTRACT: Implements type constraint objects for some common numeric types
154              
155             __END__
156              
157             =pod
158              
159             =encoding UTF-8
160              
161             =head1 NAME
162              
163             Specio::Library::Numeric - Implements type constraint objects for some common numeric types
164              
165             =head1 VERSION
166              
167             version 0.47
168              
169             =head1 DESCRIPTION
170              
171             This library provides some additional string numeric for common cases.
172              
173             =head2 PositiveNum
174              
175             =head2 PositiveOrZeroNum
176              
177             =head2 PositiveInt
178              
179             =head2 PositiveOrZeroInt
180              
181             =head2 NegativeNum
182              
183             =head2 NegativeOrZeroNum
184              
185             =head2 NegativeInt
186              
187             =head2 NegativeOrZeroInt
188              
189             =head2 SingleDigit
190              
191             A single digit from -9 to 9.
192              
193             =head1 SUPPORT
194              
195             Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>.
196              
197             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
198              
199             =head1 SOURCE
200              
201             The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>.
202              
203             =head1 AUTHOR
204              
205             Dave Rolsky <autarch@urth.org>
206              
207             =head1 COPYRIGHT AND LICENSE
208              
209             This software is Copyright (c) 2012 - 2021 by Dave Rolsky.
210              
211             This is free software, licensed under:
212              
213             The Artistic License 2.0 (GPL Compatible)
214              
215             The full text of the license can be found in the
216             F<LICENSE> file included with this distribution.
217              
218             =cut