X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F800_shikabased%2F002-coerce_multi_class.t;h=2166e3fae2c4885c52d87f49f190e630b47b1e10;hb=0d062abb99e8c296c9f5d9f6ea6a100c8bde3294;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..2166e3f 100644 --- a/t/800_shikabased/002-coerce_multi_class.t +++ b/t/800_shikabased/002-coerce_multi_class.t @@ -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; @@ -90,9 +90,11 @@ ok !$@; eval { package Response; - subtype 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } }; + type 'Headers' => where { + eval { $_->isa('Response::Headers') } + }; }; -like $@, qr/The type constraint 'Headers' has already been created, cannot be created again in Response/; +ok(!$@, "You can redefine types in their original package"); { package Request;