Finish renaming Mouse::TypeRegistry to Mouse::Util::TypeConstraints
[gitmo/Mouse.git] / t / 800_shikabased / 005-class_type.t
1 use strict;
2 use warnings;
3 use Test::More tests => 4;
4 {
5     package Response;
6     use Mouse;
7     use Mouse::Util::TypeConstraints;
8
9     class_type Headers => { class => 't::lib::ClassType_Foo' };
10     coerce 'Headers' =>
11         from 'HashRef' => via {
12             t::lib::ClassType_Foo->new(%{ $_ });
13         },
14     ;
15
16     has headers => (
17         is     => 'rw',
18         isa    => 'Headers',
19         coerce => 1,
20     );
21 }
22
23 my $res = Response->new(headers => { foo => 'bar' });
24 isa_ok($res->headers, 't::lib::ClassType_Foo');
25 is($res->headers->foo, 'bar');
26 $res->headers({foo => 'yay'});
27 isa_ok($res->headers, 't::lib::ClassType_Foo');
28 is($res->headers->foo, 'yay');