| 1 | package MooseX::Types::Common::Numeric; | ||||||||||
| 2 | # ABSTRACT: Commonly used numeric types | ||||||||||
| 3 | |||||||||||
| 4 | 1 | our $VERSION = '0.001015'; | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use MooseX::Types -declare => [ | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | qw(PositiveNum PositiveOrZeroNum | ||||||||||
| 11 | PositiveInt PositiveOrZeroInt | ||||||||||
| 12 | NegativeNum NegativeOrZeroNum | ||||||||||
| 13 | NegativeInt NegativeOrZeroInt | ||||||||||
| 14 | SingleDigit) | ||||||||||
| 15 | 1 | ]; | |||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use Moose (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use MooseX::Types::Moose qw/Num Int/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use if MooseX::Types->VERSION >= 0.42, 'namespace::autoclean'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | subtype PositiveNum, | ||||||||||
| 22 | as Num, | ||||||||||
| 23 | 0 | ▶ | where { $_ > 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 24 | 0 | ▶ | message { "Must be a positive number" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 25 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 26 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 28 | . qq{ ($_[1] > 0) }; | ||||||||||
| 29 | } | ||||||||||
| 30 | : () | ||||||||||
| 31 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | subtype PositiveOrZeroNum, | ||||||||||
| 34 | as Num, | ||||||||||
| 35 | 0 | ▶ | where { $_ >= 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 36 | 0 | ▶ | message { "Must be a number greater than or equal to zero" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 38 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 40 | . qq{ ($_[1] >= 0) }; | ||||||||||
| 41 | } | ||||||||||
| 42 | : () | ||||||||||
| 43 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | subtype PositiveInt, | ||||||||||
| 46 | as Int, | ||||||||||
| 47 | 0 | ▶ | where { $_ > 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 48 | 0 | ▶ | message { "Must be a positive integer" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 50 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 51 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 52 | . qq{ ($_[1] > 0) }; | ||||||||||
| 53 | } | ||||||||||
| 54 | : () | ||||||||||
| 55 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | |||||||||||
| 57 | subtype PositiveOrZeroInt, | ||||||||||
| 58 | as Int, | ||||||||||
| 59 | 0 | ▶ | where { $_ >= 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 60 | 0 | ▶ | message { "Must be an integer greater than or equal to zero" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 61 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 62 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 63 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 64 | . qq{ ($_[1] >= 0) }; | ||||||||||
| 65 | } | ||||||||||
| 66 | : () | ||||||||||
| 67 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | |||||||||||
| 69 | subtype NegativeNum, | ||||||||||
| 70 | as Num, | ||||||||||
| 71 | 0 | ▶ | where { $_ < 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 72 | 0 | ▶ | message { "Must be a negative number" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 73 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 74 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 75 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 76 | . qq{ ($_[1] < 0) }; | ||||||||||
| 77 | } | ||||||||||
| 78 | : () | ||||||||||
| 79 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | |||||||||||
| 81 | subtype NegativeOrZeroNum, | ||||||||||
| 82 | as Num, | ||||||||||
| 83 | 0 | ▶ | where { $_ <= 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 84 | 0 | ▶ | message { "Must be a number less than or equal to zero" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 85 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 86 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 87 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 88 | . qq{ ($_[1] <= 0) }; | ||||||||||
| 89 | } | ||||||||||
| 90 | : () | ||||||||||
| 91 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | |||||||||||
| 93 | subtype NegativeInt, | ||||||||||
| 94 | as Int, | ||||||||||
| 95 | 0 | ▶ | where { $_ < 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 96 | 0 | ▶ | message { "Must be a negative integer" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 97 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 98 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 99 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 100 | . qq{ ($_[1] < 0) }; | ||||||||||
| 101 | } | ||||||||||
| 102 | : () | ||||||||||
| 103 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | |||||||||||
| 105 | subtype NegativeOrZeroInt, | ||||||||||
| 106 | as Int, | ||||||||||
| 107 | 0 | ▶ | where { $_ <= 0 }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 108 | 0 | ▶ | message { "Must be an integer less than or equal to zero" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 109 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 110 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 111 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 112 | . qq{ ($_[1] <= 0) }; | ||||||||||
| 113 | } | ||||||||||
| 114 | : () | ||||||||||
| 115 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | |||||||||||
| 117 | subtype SingleDigit, | ||||||||||
| 118 | as Int, | ||||||||||
| 119 | 0 | ▶ | where { $_ >= -9 and $_ <= 9 }, | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 120 | 0 | ▶ | message { "Must be a single digit" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 121 | ( $Moose::VERSION >= 2.0200 | ||||||||||
| 122 | 1 | ▶ | ? inline_as { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 123 | 1 | $_[0]->parent()->_inline_check( $_[1] ) . ' && ' | |||||||||
| 124 | . qq{ ($_[1] >= -9 and $_[1] <= 9) }; | ||||||||||
| 125 | } | ||||||||||
| 126 | : () | ||||||||||
| 127 | 1 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 128 | |||||||||||
| 129 | 1 | 1; | |||||||||
| 130 | |||||||||||
| 131 | __END__ | ||||||||||