X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F11-overflow.t;h=d1d17651111d440106decc03dbf960b2346ac69e;hb=52ffe972e427eeb49513e43749d09e0a4f134a3a;hp=94328eb40357d6a4b89c01bb9ccd61183e25dae4;hpb=c116e19a44d7bb0aa19f3cbc2df8a63f9ed25099;p=gitmo%2FMooseX-Types-Structured.git diff --git a/t/11-overflow.t b/t/11-overflow.t index 94328eb..d1d1765 100644 --- a/t/11-overflow.t +++ b/t/11-overflow.t @@ -1,7 +1,7 @@ BEGIN { use strict; use warnings; - use Test::More tests=>20; + use Test::More tests=>10; } use Moose::Util::TypeConstraints; @@ -22,20 +22,6 @@ ok !$array_tailed_tuple->check({}), 'correct fail'; 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_tuple = - subtype 'hash_tailed_tuple', - as Tuple[ - Int, - Str, - slurpy HashRef[Int], - ]; - -ok !$hash_tailed_tuple->check(['ss',1]), 'correct fail'; -ok $hash_tailed_tuple->check([1,'ss']), 'correct pass'; -ok !$hash_tailed_tuple->check({}), 'correct fail'; -ok $hash_tailed_tuple->check([1,'hello',age=>25,zip=>10533]), 'correct pass with tail'; -ok !$hash_tailed_tuple->check([1,'hello',age=>25,name=>'john']), 'correct fail with tail'; - my $hash_tailed_dict = subtype 'hash_tailed_dict', as Dict[ @@ -50,6 +36,22 @@ ok !$hash_tailed_dict->check([]), 'correct fail'; ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>2}), 'correct pass with tail'; ok !$hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>"aa"}), 'correct fail with tail'; +__END__ + +my $hash_tailed_tuple = + subtype 'hash_tailed_tuple', + as Tuple[ + Int, + Str, + slurpy HashRef[Int], + ]; + +ok !$hash_tailed_tuple->check(['ss',1]), 'correct fail'; +ok $hash_tailed_tuple->check([1,'ss']), 'correct pass'; +ok !$hash_tailed_tuple->check({}), 'correct fail'; +ok $hash_tailed_tuple->check([1,'hello',age=>25,zip=>10533]), 'correct pass with tail'; +ok !$hash_tailed_tuple->check([1,'hello',age=>25,name=>'john']), 'correct fail with tail'; + my $array_tailed_dict = subtype 'hash_tailed_dict', as Dict[ @@ -61,19 +63,5 @@ my $array_tailed_dict = ok !$array_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail'; ok $array_tailed_dict->check({name=>'Vanessa Li', age=>35}), 'correct pass'; 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,2,3}), '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