11 my $role1 = Moose::Meta::Role->initialize('Foo');
12 $role1->add_attribute( foo => ( is => 'ro' ) );
14 ok( $role1->has_attribute('foo'), 'Foo role has a foo attribute' );
16 my $foo_attr = $role1->get_attribute('foo');
18 $foo_attr->associated_role->name, 'Foo',
19 'associated_role for foo attr is Foo role'
23 $foo_attr->attribute_for_class('Moose::Meta::Attribute'),
24 'Moose::Meta::Attribute',
25 'attribute returned by ->attribute_for_class'
28 my $role2 = Moose::Meta::Role->initialize('Bar');
29 $role1->apply($role2);
31 ok( $role2->has_attribute('foo'), 'Bar role has a foo attribute' );
34 $foo_attr->associated_role->name, 'Foo',
35 'associated_role for foo attr is still Foo role'
39 $foo_attr->attribute_for_class('Moose::Meta::Attribute'),
40 'Moose::Meta::Attribute',
41 'attribute returned by ->attribute_for_class'
44 my $role3 = Moose::Meta::Role->initialize('Baz');
45 my $combined = Moose::Meta::Role->combine( [ $role1->name ], [ $role3->name ] );
47 ok( $combined->has_attribute('foo'), 'combined role has a foo attribute' );
50 $foo_attr->associated_role->name, 'Foo',
51 'associated_role for foo attr is still Foo role'