Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / Moose-t-failing / 030_roles / 044_role_attrs.t
CommitLineData
c47cf415 1use strict;
2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
5use warnings;
6
7use Test::More;
8$TODO = q{Mouse is not yet completed};
9use Test::Exception;
10
11use Mouse ();
12use Mouse::Meta::Role;
13use Mouse::Util;
14
15my $role1 = Mouse::Meta::Role->initialize('Foo');
16$role1->add_attribute( foo => ( is => 'ro' ) );
17
18ok( $role1->has_attribute('foo'), 'Foo role has a foo attribute' );
19
20my $foo_attr = $role1->get_attribute('foo');
21is(
22 $foo_attr->associated_role->name, 'Foo',
23 'associated_role for foo attr is Foo role'
24);
25
26isa_ok(
27 $foo_attr->attribute_for_class('Mouse::Meta::Attribute'),
28 'Mouse::Meta::Attribute',
29 'attribute returned by ->attribute_for_class'
30);
31
32my $role2 = Mouse::Meta::Role->initialize('Bar');
33$role1->apply($role2);
34
35ok( $role2->has_attribute('foo'), 'Bar role has a foo attribute' );
36
37is(
38 $foo_attr->associated_role->name, 'Foo',
39 'associated_role for foo attr is still Foo role'
40);
41
42isa_ok(
43 $foo_attr->attribute_for_class('Mouse::Meta::Attribute'),
44 'Mouse::Meta::Attribute',
45 'attribute returned by ->attribute_for_class'
46);
47
48my $role3 = Mouse::Meta::Role->initialize('Baz');
49my $combined = Mouse::Meta::Role->combine( [ $role1->name ], [ $role3->name ] );
50
51ok( $combined->has_attribute('foo'), 'combined role has a foo attribute' );
52
53is(
54 $foo_attr->associated_role->name, 'Foo',
55 'associated_role for foo attr is still Foo role'
56);
57
58done_testing;