From: Tomas Doran Date: Sun, 15 Jul 2012 18:02:23 +0000 (+0100) Subject: Moo using Moose Roles incompatibility X-Git-Tag: v1.000000~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53a29230a25d6458f79c8fd49268b421acced1f0;p=gitmo%2FMoo.git Moo using Moose Roles incompatibility --- diff --git a/xt/moo-consume-moose-role-coerce.t b/xt/moo-consume-moose-role-coerce.t new file mode 100644 index 0000000..a21a88c --- /dev/null +++ b/xt/moo-consume-moose-role-coerce.t @@ -0,0 +1,33 @@ +use strict; +use warnings; +use Test::More; + +{ + package RoleOne; + use Moose::Role; + use Moose::Util::TypeConstraints; + use namespace::autoclean; + + subtype 'Foo', as 'Int'; + coerce 'Foo', from 'Str', via { 3 }; + + has foo => ( + is => 'rw', + isa => 'Foo', + coerce => 1, + clearer => '_clear_foo', + ); +} +{ + package Class; + use Moo; # Works if use Moose.. + use namespace::clean -except => 'meta'; + + with 'RoleOne'; +} + +my $i = Class->new( foo => 'bar' ); +is $i->foo, 3; + +done_testing; +