merged
[gitmo/MooseX-Types-Structured.git] / t / 04-map.t
CommitLineData
678b4064 1use strict;
2use warnings;
3use Test::More;
25c705c4 4use Test::Fatal;
678b4064 5
6use MooseX::Types::Moose qw(Int Num);
7use MooseX::Types::Structured qw(Map);
678b4064 8
9my $type = Map[ Int, Num ];
10
11ok($type->assert_valid({ 10 => 10.5 }), "simple Int -> Num mapping");
12
25c705c4 13like( exception { $type->assert_valid({ 10.5 => 10.5 }) },
14 qr{value 10\.5}, "non-Int causes rejection on key");
678b4064 15
25c705c4 16like( exception { $type->assert_valid({ 10 => "ten and a half" }) },
17 qr{value ten and a half}, "non-Num value causes rejection on value");
678b4064 18
19ok($type->assert_valid({ }), "empty hashref is a valid mapping of any sort");
20
21done_testing;
22