remove unneeded shebangs
[gitmo/MooseX-Types-Common.git] / t / 02-numeric.t
CommitLineData
ac73ab52 1use strict;
eae6c2c4 2use warnings FATAL => 'all';
d52d9696 3use Test::More tests => 34;
3d272255 4use Test::Fatal;
ac73ab52 5
6{
7 package FooTest;
8 use Moose;
5b561c82 9 use MooseX::Types::Common::Numeric (
d52d9696 10 qw(PositiveNum PositiveOrZeroNum
11 PositiveInt PositiveOrZeroInt
12 NegativeNum NegativeOrZeroNum
13 NegativeInt NegativeOrZeroInt
14 SingleDigit)
ac73ab52 15 );
16
17 has digit => ( is => 'rw', isa => SingleDigit);
18 has posnum => ( is => 'rw', isa => PositiveNum);
19 has posint => ( is => 'rw', isa => PositiveInt);
20 has negnum => ( is => 'rw', isa => NegativeNum);
21 has negint => ( is => 'rw', isa => NegativeInt);
d52d9696 22 has posorzeronum => ( is => 'rw', isa => PositiveOrZeroNum);
23 has posorzeroint => ( is => 'rw', isa => PositiveOrZeroInt);
24 has negorzeronum => ( is => 'rw', isa => NegativeOrZeroNum);
25 has negorzeroint => ( is => 'rw', isa => NegativeOrZeroInt);
ac73ab52 26}
27
28my $ins = FooTest->new;
29
3d272255 30isnt(exception { $ins->digit(100); }, undef, 'SingleDigit');
31is(exception { $ins->digit(1); }, undef, 'SingleDigit 2');
ac73ab52 32
3d272255 33isnt(exception { $ins->posint(-100); }, undef, 'PositiveInt (-100)');
34isnt(exception { $ins->posint(0); }, undef, 'PositiveInt (0)');
35isnt(exception { $ins->posint(100.885); }, undef, 'PositiveInt (100.885)');
36is(exception { $ins->posint(100); }, undef, 'PositiveInt (100)');
37isnt(exception { $ins->posnum(0); }, undef, 'PositiveNum (0)');
38is(exception { $ins->posnum(100.885); }, undef, 'PositiveNum (100.885)');
39isnt(exception { $ins->posnum(-100.885); }, undef, 'PositiveNum (-100.885)');
40is(exception { $ins->posnum(0.0000000001); }, undef, 'PositiveNum (0.0000000001)');
ac73ab52 41
3d272255 42isnt(exception { $ins->posorzeroint(-100); }, undef, 'PositiveOrZeroInt (-100)');
43is(exception { $ins->posorzeroint(0); }, undef, 'PositiveOrZeroInt (0)');
44isnt(exception { $ins->posorzeroint(100.885); }, undef, 'PositiveOrZeroInt (100.885)');
45is(exception { $ins->posorzeroint(100); }, undef, 'PositiveOrZeroInt (100)');
46is(exception { $ins->posorzeronum(0); }, undef, 'PositiveOrZeroNum (0)');
47is(exception { $ins->posorzeronum(100.885); }, undef, 'PositiveOrZeroNum (100.885)');
48isnt(exception { $ins->posorzeronum(-100.885); }, undef, 'PositiveOrZeroNum (-100.885)');
49is(exception { $ins->posorzeronum(0.0000000001); }, undef, 'PositiveOrZeroNum (0.0000000001)');
d52d9696 50
3d272255 51isnt(exception { $ins->negint(100); }, undef, 'NegativeInt (100)');
52isnt(exception { $ins->negint(-100.885); }, undef, 'NegativeInt (-100.885)');
53is(exception { $ins->negint(-100); }, undef, 'NegativeInt (-100)');
54isnt(exception { $ins->negint(0); }, undef, 'NegativeInt (0)');
55is(exception { $ins->negnum(-100.885); }, undef, 'NegativeNum (-100.885)');
56isnt(exception { $ins->negnum(100.885); }, undef, 'NegativeNum (100.885)');
57isnt(exception { $ins->negnum(0); }, undef, 'NegativeNum (0)');
58is(exception { $ins->negnum(-0.0000000001); }, undef, 'NegativeNum (-0.0000000001)');
d52d9696 59
3d272255 60isnt(exception { $ins->negorzeroint(100); }, undef, 'NegativeOrZeroInt (100)');
61isnt(exception { $ins->negorzeroint(-100.885); }, undef, 'NegativeOrZeroInt (-100.885)');
62is(exception { $ins->negorzeroint(-100); }, undef, 'NegativeOrZeroInt (-100)');
63is(exception { $ins->negorzeroint(0); }, undef, 'NegativeOrZeroInt (0)');
64is(exception { $ins->negorzeronum(-100.885); }, undef, 'NegativeOrZeroNum (-100.885)');
65isnt(exception { $ins->negorzeronum(100.885); }, undef, 'NegativeOrZeroNum (100.885)');
66is(exception { $ins->negorzeronum(0); }, undef, 'NegativeOrZeroNum (0)');
67is(exception { $ins->negorzeronum(-0.0000000001); }, undef, 'NegativeOrZeroNum (-0.0000000001)');