use Test::Fatal instead of Test::Exception
[gitmo/MooseX-Types-Common.git] / t / 01-string.t
CommitLineData
ac73ab52 1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5use Test::More tests => 14;
3d272255 6use Test::Fatal;
ac73ab52 7
8{
9 package FooTest;
10 use Moose;
5b561c82 11 use MooseX::Types::Common::String (
ac73ab52 12 qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr),
13 );
14
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);
20}
21
22my $ins = FooTest->new;
23
3d272255 24is(exception { $ins->simplestr('') }, undef, 'SimpleStr');
25is(exception { $ins->simplestr('good string') }, undef, 'SimpleStr 2');
26isnt(exception { $ins->simplestr("bad\nstring") }, 'SimpleStr 3');
27isnt(exception { $ins->simplestr(join('', ("long string" x 25))) }, undef, 'SimpleStr 4');
ac73ab52 28
3d272255 29isnt(exception { $ins->nestr('') }, undef, 'NonEmptyStr');
30is(exception { $ins->nestr('good string') }, undef, 'NonEmptyStr 2');
31is(exception { $ins->nestr("bad\nstring") }, undef, 'NonEmptyStr 3');
32is(exception { $ins->nestr(join('', ("long string" x 25))) }, undef, 'NonEmptyStr 4');
ac73ab52 33
3d272255 34is(exception { $ins->nesimplestr('good str') }, undef, 'NonEmptySimplrStr');
35isnt(exception { $ins->nesimplestr('') }, undef, 'NonEmptyStr 2');
ac73ab52 36
3d272255 37isnt(exception { $ins->password('no') }, undef, 'Password');
38is(exception { $ins->password('okay') }, undef, 'Password 2');
ac73ab52 39
3d272255 40isnt(exception { $ins->strongpassword('notokay') }, undef, 'StrongPassword');
41is(exception { $ins->strongpassword('83773r_ch01c3') }, undef, 'StrongPassword 2');