3 use Test::More tests=>12;
5 use Moose::Util::TypeConstraints;
6 use MooseX::Types::Structured qw(Dict Tuple slurpy);
7 use MooseX::Types::Moose qw(Int Str ArrayRef HashRef Object);
9 my $array_tailed_tuple =
16 is($array_tailed_tuple->name, 'MooseX::Types::Structured::Tuple[Int,Str,slurpy ArrayRef[Int]]');
18 ok !$array_tailed_tuple->check(['ss',1]), 'correct fail';
19 ok $array_tailed_tuple->check([1,'ss']), 'correct pass';
20 ok !$array_tailed_tuple->check({}), 'correct fail';
21 ok $array_tailed_tuple->check([1,'hello',1,2,3,4]), 'correct pass with tail';
22 ok !$array_tailed_tuple->check([1,'hello',1,2,'bad',4]), 'correct fail with tail';
24 my $hash_tailed_dict =
31 is($hash_tailed_dict->name, 'MooseX::Types::Structured::Dict[name,Str,age,Int,slurpy HashRef[Int]]');
33 ok !$hash_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail';
34 ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35}), 'correct pass';
35 ok !$hash_tailed_dict->check([]), 'correct fail';
36 ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>2}), 'correct pass with tail';
37 ok !$hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>"aa"}), 'correct fail with tail';