line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Repl::Spec::Type::IntegerRange - A parameter guard for integers.
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This type guard ensures that an integer parameter was passed by the user.
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 Methods
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=over 4
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=item C
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=item C
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Parameters: A single expression.
|
20
|
|
|
|
|
|
|
Returns: The integer value.
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item C
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SEE ALSO
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
L
|
27
|
|
|
|
|
|
|
L
|
28
|
|
|
|
|
|
|
L
|
29
|
|
|
|
|
|
|
L
|
30
|
|
|
|
|
|
|
L
|
31
|
|
|
|
|
|
|
L
|
32
|
|
|
|
|
|
|
L
|
33
|
|
|
|
|
|
|
L
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package Repl::Spec::Type::IntegerType;
|
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
2
|
|
2114
|
use strict;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
40
|
2
|
|
|
2
|
|
9
|
use warnings;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
41
|
2
|
|
|
2
|
|
10
|
use Carp;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1411
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# No arguments required.
|
44
|
|
|
|
|
|
|
sub new
|
45
|
|
|
|
|
|
|
{
|
46
|
7
|
|
|
7
|
1
|
26
|
my $invocant = shift;
|
47
|
7
|
|
33
|
|
|
40
|
my $class = ref($invocant) || $invocant;
|
48
|
|
|
|
|
|
|
|
49
|
7
|
|
|
|
|
11
|
my $self= {};
|
50
|
7
|
|
|
|
|
68
|
return bless $self, $class;
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub guard
|
54
|
|
|
|
|
|
|
{
|
55
|
8
|
|
|
8
|
1
|
10
|
my $self = shift;
|
56
|
8
|
|
|
|
|
10
|
my $arg = shift;
|
57
|
|
|
|
|
|
|
|
58
|
8
|
100
|
|
|
|
50
|
return $arg if $arg =~ /[+-]?\d+/;
|
59
|
1
|
|
|
|
|
122
|
croak sprintf("Expected type integer but received '%s'.", $arg);
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub name
|
63
|
|
|
|
|
|
|
{
|
64
|
2
|
|
|
2
|
1
|
8
|
return 'integer';
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1;
|