From: Tomas Doran Date: Sat, 5 May 2012 19:34:22 +0000 (+0100) Subject: Fail for has '+attr' when attr comes from a Moo role X-Git-Tag: v0.091003~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=467645509697190765e698c7aee958c42dab660b;p=gitmo%2FMoo.git Fail for has '+attr' when attr comes from a Moo role --- diff --git a/xt/moose-override-attribute-from-moo-role.t b/xt/moose-override-attribute-from-moo-role.t new file mode 100644 index 0000000..8ba09c9 --- /dev/null +++ b/xt/moose-override-attribute-from-moo-role.t @@ -0,0 +1,41 @@ +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +{ + package MyRole; + use Moo::Role; + + has foo => ( + is => 'ro', + required => 1, + ); +} +{ + package MyClass; + use Moose; + + with 'MyRole'; + + has '+foo' => ( + isa => 'Str', + ); +} + +is( + exception { MyClass->new(foo => 'bar') }, + undef, + 'construct' +); +ok( + exception { MyClass->new(foo => []) }, + 'no construct, constraint works' +); +ok( + exception { MyClass->new() }, + 'no construct - require still works' +); + +done_testing; +