X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F800_shikabased%2F002-coerce_multi_class.t;h=0e2d9039e6ed8bb03afbda5486040e8ebfbbe3c2;hb=7f408f4aa3fc94662299107b1e1cc78818121ae4;hp=2bfd2d251f28b3d3166a112d50f4206f8a3fc08f;hpb=3b46bd4991dea7ead4e7f52a089222d24554e2bd;p=gitmo%2FMouse.git diff --git a/t/800_shikabased/002-coerce_multi_class.t b/t/800_shikabased/002-coerce_multi_class.t index 2bfd2d2..0e2d903 100644 --- a/t/800_shikabased/002-coerce_multi_class.t +++ b/t/800_shikabased/002-coerce_multi_class.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 13; { package Response::Headers; @@ -18,7 +18,7 @@ use Test::More tests => 14; use Mouse; use Mouse::Util::TypeConstraints; - subtype 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } }; + type 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } }; coerce 'Headers' => from 'HashRef' => via { Response::Headers->new(%{ $_ }); @@ -36,9 +36,9 @@ eval { package Request; use Mouse::Util::TypeConstraints; - subtype 'Headers' => where { defined $_ && eval { $_->isa('Request::Headers') } }; + type 'Headers' => where { defined $_ && eval { $_->isa('Request::Headers') } }; }; -like $@, qr/The type constraint 'Headers' has already been created, cannot be created again in Request/; +like $@, qr/The type constraint 'Headers' has already been created in Response and cannot be created again in Request/; eval { package Request; @@ -68,13 +68,13 @@ eval { package Request; use Mouse::Util::TypeConstraints; - coerce 'Headers' => - from 'HashRefa' => via { - Request::Headers->new(%{ $_ }); + coerce 'Int' => + from 'XXX' => via { + 1 }, ; }; -like $@, qr/Could not find the type constraint \(HashRefa\) to coerce from/; +like $@, qr/Could not find the type constraint \(XXX\) to coerce from/; eval { package Request; @@ -88,12 +88,6 @@ eval { }; ok !$@; -eval { - package Response; - subtype 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } }; -}; -like $@, qr/The type constraint 'Headers' has already been created, cannot be created again in Response/; - { package Request; use Mouse; @@ -105,7 +99,6 @@ like $@, qr/The type constraint 'Headers' has already been created, cannot be cr ); } - my $req = Request->new(headers => { foo => 'bar' }); isa_ok($req->headers, 'Response::Headers'); is($req->headers->foo, 'bar'); @@ -119,3 +112,4 @@ is($res->headers->foo, 'bar'); $res->headers({foo => 'yay'}); isa_ok($res->headers, 'Response::Headers'); is($res->headers->foo, 'yay'); +