X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01-string.t;h=611a84afffa7b9f1f47b5d0d6ec9a4c615d3d823;hb=a5c9a43331cadecc264704887a3ef1b4ad4c7f0e;hp=7632b703475ea49158eed6d2b459d9191ee96cb9;hpb=5b561c82b0ff0435257c040a68a33dcec5c58e93;p=gitmo%2FMooseX-Types-Common.git diff --git a/t/01-string.t b/t/01-string.t index 7632b70..611a84a 100644 --- a/t/01-string.t +++ b/t/01-string.t @@ -2,40 +2,64 @@ use strict; use warnings; -use Test::More tests => 14; -use Test::Exception; +use Test::More tests => 22; +use Test::Fatal; { package FooTest; use Moose; use MooseX::Types::Common::String ( - qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr), + qw(SimpleStr + NonEmptySimpleStr + LowerCaseSimpleStr + UpperCaseSimpleStr + Password + StrongPassword + NonEmptyStr + LowerCaseStr + UpperCaseStr), ); - has simplestr => ( is => 'rw', isa => SimpleStr); - has nestr => ( is => 'rw', isa => NonEmptyStr); - has nesimplestr => ( is => 'rw', isa => NonEmptySimpleStr); - has password => ( is => 'rw', isa => Password); - has strongpassword => ( is => 'rw', isa => StrongPassword); + has simplestr => ( is => 'rw', isa => SimpleStr ); + has nestr => ( is => 'rw', isa => NonEmptyStr ); + has nesimplestr => ( is => 'rw', isa => NonEmptySimpleStr ); + has lcsimplestr => ( is => 'rw', isa => LowerCaseSimpleStr ); + has ucsimplestr => ( is => 'rw', isa => UpperCaseSimpleStr ); + has password => ( is => 'rw', isa => Password ); + has strongpassword => ( is => 'rw', isa => StrongPassword ); + has lowercasestr => ( is => 'rw', isa => LowerCaseStr ); + has uppercasestr => ( is => 'rw', isa => UpperCaseStr ); } my $ins = FooTest->new; -lives_ok { $ins->simplestr('') } 'SimpleStr'; -lives_ok { $ins->simplestr('good string') } 'SimpleStr 2'; -dies_ok { $ins->simplestr("bad\nstring") } 'SimpleStr 3'; -dies_ok { $ins->simplestr(join('', ("long string" x 25))) } 'SimpleStr 4'; +is(exception { $ins->simplestr('') }, undef, 'SimpleStr'); +is(exception { $ins->simplestr('good string') }, undef, 'SimpleStr 2'); +isnt(exception { $ins->simplestr("bad\nstring") }, 'SimpleStr 3'); +isnt(exception { $ins->simplestr(join('', ("long string" x 25))) }, undef, 'SimpleStr 4'); -dies_ok { $ins->nestr('') } 'NonEmptyStr'; -lives_ok { $ins->nestr('good string') } 'NonEmptyStr 2'; -lives_ok { $ins->nestr("bad\nstring") } 'NonEmptyStr 3'; -lives_ok { $ins->nestr(join('', ("long string" x 25))) } 'NonEmptyStr 4'; +isnt(exception { $ins->nestr('') }, undef, 'NonEmptyStr'); +is(exception { $ins->nestr('good string') }, undef, 'NonEmptyStr 2'); +is(exception { $ins->nestr("bad\nstring") }, undef, 'NonEmptyStr 3'); +is(exception { $ins->nestr(join('', ("long string" x 25))) }, undef, 'NonEmptyStr 4'); -lives_ok { $ins->nesimplestr('good str') } 'NonEmptySimplrStr '; -dies_ok { $ins->nesimplestr('') } 'NonEmptyStr 2'; +is(exception { $ins->nesimplestr('good str') }, undef, 'NonEmptySimplrStr'); +isnt(exception { $ins->nesimplestr('') }, undef, 'NonEmptyStr 2'); -dies_ok { $ins->password('no') } 'Password'; -lives_ok { $ins->password('okay') } 'Password 2'; +isnt(exception { $ins->password('no') }, undef, 'Password'); +is(exception { $ins->password('okay') }, undef, 'Password 2'); -dies_ok { $ins->strongpassword('notokay') } 'StrongPassword'; -lives_ok { $ins->strongpassword('83773r_ch01c3') } 'StrongPassword 2'; +isnt(exception { $ins->strongpassword('notokay') }, undef, 'StrongPassword'); +is(exception { $ins->strongpassword('83773r_ch01c3') }, undef, 'StrongPassword 2'); + +isnt(exception { $ins->lcsimplestr('NOTOK') }, undef, 'LowerCaseSimpleStr'); +is(exception { $ins->lcsimplestr('ok') }, undef, 'LowerCaseSimpleStr 2'); + +isnt(exception { $ins->ucsimplestr('notok') }, undef, 'UpperCaseSimpleStr'); +is(exception { $ins->ucsimplestr('OK') }, undef, 'UpperCaseSimpleStr 2'); + +isnt(exception { $ins->lowercasestr('NOTOK') }, undef, 'LowerCaseStr'); +is(exception { $ins->lowercasestr('ok') }, undef, 'LowerCaseStr 2'); + +isnt(exception { $ins->uppercasestr('notok') }, undef, 'UpperCaseStr'); +is(exception { $ins->uppercasestr('OK') }, undef, 'UpperCaseStr 2');