From: Florian Ragwitz Date: Fri, 1 May 2009 07:13:20 +0000 (+0200) Subject: Add tests for names of types with overflow handlers. X-Git-Tag: 0.14~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Structured.git;a=commitdiff_plain;h=a61f836a862c6e44dcdbdd87ae74742ec5578121 Add tests for names of types with overflow handlers. --- diff --git a/t/11-overflow.t b/t/11-overflow.t index d1d1765..6a16706 100644 --- a/t/11-overflow.t +++ b/t/11-overflow.t @@ -1,21 +1,20 @@ -BEGIN { - use strict; - use warnings; - use Test::More tests=>10; -} +use strict; +use warnings; +use Test::More tests=>12; use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple slurpy); use MooseX::Types::Moose qw(Int Str ArrayRef HashRef Object); my $array_tailed_tuple = - subtype 'array_tailed_tuple', - as Tuple[ + Tuple[ Int, Str, slurpy ArrayRef[Int], ]; - + +is($array_tailed_tuple->name, 'MooseX::Types::Structured::Tuple[Int,Str,slurpy ArrayRef[Int]]'); + ok !$array_tailed_tuple->check(['ss',1]), 'correct fail'; ok $array_tailed_tuple->check([1,'ss']), 'correct pass'; ok !$array_tailed_tuple->check({}), 'correct fail'; @@ -23,13 +22,14 @@ ok $array_tailed_tuple->check([1,'hello',1,2,3,4]), 'correct pass with tail'; ok !$array_tailed_tuple->check([1,'hello',1,2,'bad',4]), 'correct fail with tail'; my $hash_tailed_dict = - subtype 'hash_tailed_dict', - as Dict[ + Dict[ name=>Str, age=>Int, slurpy HashRef[Int], ]; - + +is($hash_tailed_dict->name, 'MooseX::Types::Structured::Dict[name,Str,age,Int,slurpy HashRef[Int]]'); + ok !$hash_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail'; ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35}), 'correct pass'; ok !$hash_tailed_dict->check([]), 'correct fail';