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