X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F11-overflow.t;h=94328eb40357d6a4b89c01bb9ccd61183e25dae4;hb=c116e19a44d7bb0aa19f3cbc2df8a63f9ed25099;hp=949061d3a1a13673496eede5ae5684dfbfcb8468;hpb=ff801143e71409963bb8b0600118409247c1995b;p=gitmo%2FMooseX-Types-Structured.git diff --git a/t/11-overflow.t b/t/11-overflow.t index 949061d..94328eb 100644 --- a/t/11-overflow.t +++ b/t/11-overflow.t @@ -5,17 +5,15 @@ BEGIN { } use Moose::Util::TypeConstraints; -use MooseX::Types::Structured qw(Dict Tuple); -use MooseX::Types::Moose qw(Int Str ArrayRef HashRef); +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[ Int, Str, - sub { - (ArrayRef[Int])->check([@_]); - }, + slurpy ArrayRef[Int], ]; ok !$array_tailed_tuple->check(['ss',1]), 'correct fail'; @@ -29,9 +27,7 @@ my $hash_tailed_tuple = as Tuple[ Int, Str, - sub { - (HashRef[Int])->check({@_}); - }, + slurpy HashRef[Int], ]; ok !$hash_tailed_tuple->check(['ss',1]), 'correct fail'; @@ -45,9 +41,7 @@ my $hash_tailed_dict = as Dict[ name=>Str, age=>Int, - sub { - (HashRef[Int])->check({@_}); - } + slurpy HashRef[Int], ]; ok !$hash_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail'; @@ -61,9 +55,7 @@ my $array_tailed_dict = as Dict[ name=>Str, age=>Int, - sub { - (ArrayRef[Int])->check([@_]); - } + slurpy ArrayRef[Int], ]; ok !$array_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail'; @@ -72,3 +64,16 @@ ok !$array_tailed_dict->check([]), 'correct fail'; ok $array_tailed_dict->check({name=>'Vanessa Li', age=>35, 1,2}), 'correct pass with tail'; ok !$array_tailed_dict->check({name=>'Vanessa Li', age=>35, 1, "hello"}), 'correct fail with tail'; +my $insane_tc = + subtype 'insane_tc', + as Tuple[ + Object, + slurpy Dict[ + name=>Str, + age=>Int, + slurpy ArrayRef[Int], + ] + ]; + +ok $insane_tc->check([$insane_tc, name=>"John", age=>25, 1,2,3]), + 'validated: [$insane_tc, name=>"John", age=>25, 1,2,3]'; \ No newline at end of file