make sure to clear the stash when anon classes are removed explicitly
[gitmo/Moose.git] / t / roles / role_attr_application.t
index 2f6463b..5c53ce5 100644 (file)
@@ -243,13 +243,50 @@ ok(!Moose::Util::does_role(Baz->meta->get_attribute('foo'), 'Baz::Meta::Attribut
     my $baz = Quux->meta->get_attribute('baz');
     ok(! does_role($baz, 'Quux::Meta::Role::Attribute'),
        "applied_attribute traits do not end up applying to attributes from other roles during composition");
-}
 
-{
-    local $TODO = "applied_attribute metaroles are lost in role composition";
     my $bar = Quux->meta->get_attribute('bar');
     does_ok($bar, 'Quux::Meta::Role::Attribute',
             "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;