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_ok('Moose::Util::TypeConstraints');
34 use Moose::Util::TypeConstraints;
37 eq_deeply array_each subhashof ignore
40 # define your own type ...
41 type 'ArrayOfHashOfBarsAndRandomNumbers'
46 bar => Test::Deep::isa('Bar'),
47 random_number => ignore()
55 isa => 'ArrayOfHashOfBarsAndRandomNumbers',
62 my $array_of_hashes = [
63 { bar => Bar->new, random_number => 10 },
69 $foo = Foo->new('bar' => $array_of_hashes);
70 } '... construction succeeded';
73 is_deeply($foo->bar, $array_of_hashes, '... got our value correctly');
77 } '... validation failed correctly';
80 $foo->bar([{ foo => 3 }]);
81 } '... validation failed correctly';