X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Structured.git;a=blobdiff_plain;f=t%2F11-overflow.t;h=a57f327f0dceb06af6dbf97df376b211062756e3;hp=949061d3a1a13673496eede5ae5684dfbfcb8468;hb=3b14bb98e22d08e5e9f75e16d02ca3a4685dcac7;hpb=ff801143e71409963bb8b0600118409247c1995b diff --git a/t/11-overflow.t b/t/11-overflow.t index 949061d..a57f327 100644 --- a/t/11-overflow.t +++ b/t/11-overflow.t @@ -8,14 +8,21 @@ use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str ArrayRef HashRef); + +sub merge(&$) { + my ($code, $tc) = @_; + return sub { + my @tail_args = @_; + $tc->check($code->(@tail_args)); + } +} + my $array_tailed_tuple = subtype 'array_tailed_tuple', as Tuple[ Int, Str, - sub { - (ArrayRef[Int])->check([@_]); - }, + merge {[@_]} ArrayRef[Int], ]; ok !$array_tailed_tuple->check(['ss',1]), 'correct fail'; @@ -29,9 +36,7 @@ my $hash_tailed_tuple = as Tuple[ Int, Str, - sub { - (HashRef[Int])->check({@_}); - }, + merge {+{@_}} HashRef[Int], ]; ok !$hash_tailed_tuple->check(['ss',1]), 'correct fail'; @@ -45,9 +50,7 @@ my $hash_tailed_dict = as Dict[ name=>Str, age=>Int, - sub { - (HashRef[Int])->check({@_}); - } + merge {+{@_}} HashRef[Int], ]; ok !$hash_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail'; @@ -61,9 +64,7 @@ my $array_tailed_dict = as Dict[ name=>Str, age=>Int, - sub { - (ArrayRef[Int])->check([@_]); - } + merge {[@_]} ArrayRef[Int], ]; ok !$array_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail';