6 use Test::More tests => 17;
10 use_ok('Moose::Role');
20 our $VERSION = '0.01';
22 has 'bar' => (is => 'rw', isa => 'Foo');
23 has 'baz' => (is => 'ro');
25 sub foo { 'FooRole::foo' }
27 before 'boo' => sub { "FooRole::boo:before" };
30 my $foo_role = FooRole->meta;
31 isa_ok($foo_role, 'Moose::Meta::Role');
33 isa_ok($foo_role->role_meta, 'Class::MOP::Class');
35 is($foo_role->name, 'FooRole', '... got the right name of FooRole');
36 is($foo_role->version, '0.01', '... got the right version of FooRole');
40 ok($foo_role->has_method('foo'), '... FooRole has the foo method');
41 is($foo_role->get_method('foo'), \&FooRole::foo, '... FooRole got the foo method');
43 isa_ok($foo_role->get_method('foo'), 'Moose::Meta::Role::Method');
46 [ $foo_role->get_method_list() ],
48 '... got the right method list');
53 [ sort $foo_role->get_attribute_list() ],
55 '... got the right attribute list');
57 ok($foo_role->has_attribute('bar'), '... FooRole does have the bar attribute');
60 $foo_role->get_attribute('bar'),
61 { is => 'rw', isa => 'Foo' },
62 '... got the correct description of the bar attribute');
64 ok($foo_role->has_attribute('baz'), '... FooRole does have the baz attribute');
67 $foo_role->get_attribute('baz'),
69 '... got the correct description of the baz attribute');
73 ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier');
74 is(($foo_role->get_before_method_modifiers('boo'))[0]->(),
75 "FooRole::boo:before",
76 '... got the right method back');
79 [ $foo_role->get_method_modifier_list('before') ],
81 '... got the right list of before method modifiers');