shut up the test eol complaints
[gitmo/MooseX-Types-Structured.git] / t / 11-overflow.t
CommitLineData
a61f836a 1use strict;
2use warnings;
3use Test::More tests=>12;
ff801143 4
5use Moose::Util::TypeConstraints;
c116e19a 6use MooseX::Types::Structured qw(Dict Tuple slurpy);
7use MooseX::Types::Moose qw(Int Str ArrayRef HashRef Object);
3b14bb98 8
ff801143 9my $array_tailed_tuple =
a61f836a 10 Tuple[
ff801143 11 Int,
12 Str,
c116e19a 13 slurpy ArrayRef[Int],
ff801143 14 ];
a61f836a 15
16is($array_tailed_tuple->name, 'MooseX::Types::Structured::Tuple[Int,Str,slurpy ArrayRef[Int]]');
17
ff801143 18ok !$array_tailed_tuple->check(['ss',1]), 'correct fail';
19ok $array_tailed_tuple->check([1,'ss']), 'correct pass';
20ok !$array_tailed_tuple->check({}), 'correct fail';
21ok $array_tailed_tuple->check([1,'hello',1,2,3,4]), 'correct pass with tail';
22ok !$array_tailed_tuple->check([1,'hello',1,2,'bad',4]), 'correct fail with tail';
23
ff801143 24my $hash_tailed_dict =
a61f836a 25 Dict[
ff801143 26 name=>Str,
27 age=>Int,
c116e19a 28 slurpy HashRef[Int],
ff801143 29 ];
a61f836a 30
31is($hash_tailed_dict->name, 'MooseX::Types::Structured::Dict[name,Str,age,Int,slurpy HashRef[Int]]');
32
ff801143 33ok !$hash_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail';
34ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35}), 'correct pass';
35ok !$hash_tailed_dict->check([]), 'correct fail';
36ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>2}), 'correct pass with tail';
37ok !$hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>"aa"}), 'correct fail with tail';
38