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