X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fmoo-does-moose-role.t;h=887297148bc72e65cb6c36379e05a4bd6167dbf7;hb=37d01587f30001c09141f8cddeecd99d31557c0d;hp=ff9f6d25b880af951d7e138be4edf9c9dba32745;hpb=b6ab68373c2cde43fa4c53494e09624ea050e545;p=gitmo%2FMoo.git diff --git a/xt/moo-does-moose-role.t b/xt/moo-does-moose-role.t index ff9f6d2..8872971 100644 --- a/xt/moo-does-moose-role.t +++ b/xt/moo-does-moose-role.t @@ -234,4 +234,33 @@ is( Plonker->meta->find_attribute_by_name('kk')->documentation, 'parentchild', 'moosify applies for overridden attributes with roles'); +{ + package MooseAttrTrait; + use Moose::Role; + + has 'extra_attr' => (is => 'ro'); + has 'extra_attr_noinit' => (is => 'ro', init_arg => undef); +} + +{ + local $SIG{__WARN__} = sub { fail "warning: $_[0]" }; + package UsingMooseTrait; + use Moo; + + has one => ( + is => 'ro', + traits => ['MooseAttrTrait'], + extra_attr => 'one', + extra_attr_noinit => 'two', + ); +} + +ok( UsingMooseTrait->meta + ->find_attribute_by_name('one')->can('extra_attr'), + 'trait was properly applied'); +is( UsingMooseTrait->meta->find_attribute_by_name('one') + ->extra_attr, + 'one', + 'trait attributes maintain values'); + done_testing;