10 This tests how well Moose type constraints
13 Its not as pretty as Declare::Constraints::Simple,
14 but it is not completely horrid either.
19 eval "use Test::Deep;";
20 plan skip_all => "Test::Deep is required for this test" if $@;
28 use Moose::Util::TypeConstraints;
31 eq_deeply array_each subhashof ignore
34 # define your own type ...
35 type 'ArrayOfHashOfBarsAndRandomNumbers'
40 bar => Test::Deep::isa('Bar'),
41 random_number => ignore()
49 isa => 'ArrayOfHashOfBarsAndRandomNumbers',
56 my $array_of_hashes = [
57 { bar => Bar->new, random_number => 10 },
63 $foo = Foo->new('bar' => $array_of_hashes);
64 } '... construction succeeded';
67 is_deeply($foo->bar, $array_of_hashes, '... got our value correctly');
71 } '... validation failed correctly';
74 $foo->bar([{ foo => 3 }]);
75 } '... validation failed correctly';