5 use MooseX::Types::Moose qw(Int Num);
6 use MooseX::Types::Structured qw(Map);
8 my $type = Map[ Int, Num ];
10 ok($type->assert_valid({ 10 => 10.5 }), "simple Int -> Num mapping");
12 eval { $type->assert_valid({ 10.5 => 10.5 }) };
13 like($@, qr{value 10\.5}, "non-Int causes rejection on key");
15 eval { $type->assert_valid({ 10 => "ten and a half" }) };
16 like("$@", qr{value ten and a half}, "non-Num value causes rejection on value");
18 ok($type->assert_valid({ }), "empty hashref is a valid mapping of any sort");