From: Dave Rolsky Date: Mon, 14 Mar 2011 03:58:22 +0000 (-0500) Subject: Add test for applied_attribute traits being lost when one role consumes another role X-Git-Tag: 1.9905~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9731c39a959c1b17f5efa0b9935634ef5e0f3fa;p=gitmo%2FMoose.git Add test for applied_attribute traits being lost when one role consumes another role --- diff --git a/t/roles/role_attr_application.t b/t/roles/role_attr_application.t index 2f6463b..00fd53b 100644 --- a/t/roles/role_attr_application.t +++ b/t/roles/role_attr_application.t @@ -252,4 +252,44 @@ ok(!Moose::Util::does_role(Baz->meta->get_attribute('foo'), 'Baz::Meta::Attribut "attribute metarole applied correctly"); } +{ + package HasMeta; + use Moose::Role; + Moose::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + role_metaroles => { + applied_attribute => ['Quux::Meta::Role::Attribute'] + }, + ); + + has foo => (is => 'ro'); +} + +{ + package NoMeta; + use Moose::Role; + + with 'HasMeta'; + + has bar => (is => 'ro'); +} + +{ + package ConsumesBoth; + use Moose; + with 'HasMeta', 'NoMeta'; +} + +{ + my $foo = ConsumesBoth->meta->get_attribute('foo'); + does_ok($foo, 'Quux::Meta::Role::Attribute', + 'applied_attribute traits are preserved when one role consumes another'); + + my $bar = ConsumesBoth->meta->get_attribute('bar'); + ok(! does_role($bar, 'Quux::Meta::Role::Attribute'), + "applied_attribute traits do not spill over from consumed role"); +} + + + done_testing;