5 use Test::More tests => 26;
11 use MooseX::Types::Common (
12 qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr),
13 qw(PositiveNum PositiveInt NegativeInt NegativeNum SingleDigit)
16 has simplestr => ( is => 'rw', isa => SimpleStr);
17 has nestr => ( is => 'rw', isa => NonEmptyStr);
18 has nesimplestr => ( is => 'rw', isa => NonEmptySimpleStr);
19 has password => ( is => 'rw', isa => Password);
20 has strongpassword => ( is => 'rw', isa => StrongPassword);
22 has digit => ( is => 'rw', isa => SingleDigit);
23 has posnum => ( is => 'rw', isa => PositiveNum);
24 has posint => ( is => 'rw', isa => PositiveInt);
25 has negnum => ( is => 'rw', isa => NegativeNum);
26 has negint => ( is => 'rw', isa => NegativeInt);
29 my $ins = FooTest->new;
31 lives_ok { $ins->simplestr('') } 'SimpleStr';
32 lives_ok { $ins->simplestr('good string') } 'SimpleStr 2';
33 dies_ok { $ins->simplestr("bad\nstring") } 'SimpleStr 3';
34 dies_ok { $ins->simplestr(join('', ("long string" x 25))) } 'SimpleStr 4';
36 dies_ok { $ins->nestr('') } 'NonEmptyStr';
37 lives_ok { $ins->nestr('good string') } 'NonEmptyStr 2';
38 lives_ok { $ins->nestr("bad\nstring") } 'NonEmptyStr 3';
39 lives_ok { $ins->nestr(join('', ("long string" x 25))) } 'NonEmptyStr 4';
41 lives_ok { $ins->nesimplestr('good str') } 'NonEmptySimplrStr ';
42 dies_ok { $ins->nesimplestr('') } 'NonEmptyStr 2';
44 dies_ok { $ins->password('no') } 'Password';
45 lives_ok { $ins->password('okay') } 'Password 2';
47 dies_ok { $ins->strongpassword('notokay') } 'StrongPassword';
48 lives_ok { $ins->strongpassword('83773r_ch01c3') } 'StrongPassword 2';
50 dies_ok { $ins->digit(100); } 'SingleDigit';
51 lives_ok { $ins->digit(1); } 'SingleDigit 2';
53 dies_ok { $ins->posint(-100); } 'PositiveInt';
54 dies_ok { $ins->posint(100.885); } 'PositiveInt 2';
55 lives_ok { $ins->posint(100); } 'PositiveInt 3';
56 lives_ok { $ins->posnum(100.885); } 'PositiveNum';
57 dies_ok { $ins->posnum(-100.885); } 'PositiveNum 2';
59 dies_ok { $ins->negint(100); } 'NegativeInt';
60 dies_ok { $ins->negint(-100.885); } 'NegativeInt 2';
61 lives_ok { $ins->negint(-100); } 'NegativeInt 3';
62 lives_ok { $ins->negnum(-100.885); } 'NegativeNum';
63 dies_ok { $ins->negnum(100.885); } 'NegativeNum 2';