2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
13 This tests how well Mouse type constraints
14 play with Declare::Constraints::Simple.
16 Pretty well if I do say so myself :)
21 'Declare::Constraints::Simple' => '0.01', # skip all if not installed
29 use Mouse::Util::TypeConstraints;
30 use Declare::Constraints::Simple -All;
32 # define your own type ...
33 type( 'HashOfArrayOfObjects',
37 -values => IsArrayRef(IsObject)
43 isa => 'HashOfArrayOfObjects',
46 # inline the constraints as anon-subtypes
49 isa => subtype( { as => 'ArrayRef', where => IsArrayRef(IsInt) } ),
56 my $hash_of_arrays_of_objs = {
58 foo2 => [ Bar->new, Bar->new ],
61 my $array_of_ints = [ 1 .. 10 ];
66 'bar' => $hash_of_arrays_of_objs,
67 'baz' => $array_of_ints,
69 } '... construction succeeded';
72 is_deeply($foo->bar, $hash_of_arrays_of_objs, '... got our value correctly');
73 is_deeply($foo->baz, $array_of_ints, '... got our value correctly');
77 } '... validation failed correctly';
80 $foo->bar({ foo => 3 });
81 } '... validation failed correctly';
84 $foo->bar({ foo => [ 1, 2, 3 ] });
85 } '... validation failed correctly';
89 } '... validation failed correctly';
93 } '... validation failed correctly';