10 my $role1 = Moose::Meta::Role->initialize('Foo');
11 $role1->add_attribute( foo => ( is => 'ro' ) );
13 ok( $role1->has_attribute('foo'), 'Foo role has a foo attribute' );
15 my $foo_attr = $role1->get_attribute('foo');
17 $foo_attr->associated_role->name, 'Foo',
18 'associated_role for foo attr is Foo role'
22 $foo_attr->attribute_for_class('Moose::Meta::Attribute'),
23 'Moose::Meta::Attribute',
24 'attribute returned by ->attribute_for_class'
27 my $role2 = Moose::Meta::Role->initialize('Bar');
28 $role1->apply($role2);
30 ok( $role2->has_attribute('foo'), 'Bar role has a foo attribute' );
33 $foo_attr->associated_role->name, 'Foo',
34 'associated_role for foo attr is still Foo role'
38 $foo_attr->attribute_for_class('Moose::Meta::Attribute'),
39 'Moose::Meta::Attribute',
40 'attribute returned by ->attribute_for_class'
43 my $role3 = Moose::Meta::Role->initialize('Baz');
44 my $combined = Moose::Meta::Role->combine( [ $role1->name ], [ $role3->name ] );
46 ok( $combined->has_attribute('foo'), 'combined role has a foo attribute' );
49 $foo_attr->associated_role->name, 'Foo',
50 'associated_role for foo attr is still Foo role'