5 use Test::More tests => 14;
11 use MooseX::Types::Common::String (
12 qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr),
15 has simplestr => ( is => 'rw', isa => SimpleStr);
16 has nestr => ( is => 'rw', isa => NonEmptyStr);
17 has nesimplestr => ( is => 'rw', isa => NonEmptySimpleStr);
18 has password => ( is => 'rw', isa => Password);
19 has strongpassword => ( is => 'rw', isa => StrongPassword);
22 my $ins = FooTest->new;
24 is(exception { $ins->simplestr('') }, undef, 'SimpleStr');
25 is(exception { $ins->simplestr('good string') }, undef, 'SimpleStr 2');
26 isnt(exception { $ins->simplestr("bad\nstring") }, 'SimpleStr 3');
27 isnt(exception { $ins->simplestr(join('', ("long string" x 25))) }, undef, 'SimpleStr 4');
29 isnt(exception { $ins->nestr('') }, undef, 'NonEmptyStr');
30 is(exception { $ins->nestr('good string') }, undef, 'NonEmptyStr 2');
31 is(exception { $ins->nestr("bad\nstring") }, undef, 'NonEmptyStr 3');
32 is(exception { $ins->nestr(join('', ("long string" x 25))) }, undef, 'NonEmptyStr 4');
34 is(exception { $ins->nesimplestr('good str') }, undef, 'NonEmptySimplrStr');
35 isnt(exception { $ins->nesimplestr('') }, undef, 'NonEmptyStr 2');
37 isnt(exception { $ins->password('no') }, undef, 'Password');
38 is(exception { $ins->password('okay') }, undef, 'Password 2');
40 isnt(exception { $ins->strongpassword('notokay') }, undef, 'StrongPassword');
41 is(exception { $ins->strongpassword('83773r_ch01c3') }, undef, 'StrongPassword 2');