6 use Test::More tests => 16;
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');
44 [ $foo_role->get_method_list() ],
46 '... got the right method list');
51 [ sort $foo_role->get_attribute_list() ],
53 '... got the right attribute list');
55 ok($foo_role->has_attribute('bar'), '... FooRole does have the bar attribute');
58 $foo_role->get_attribute('bar'),
59 { is => 'rw', isa => 'Foo' },
60 '... got the correct description of the bar attribute');
62 ok($foo_role->has_attribute('baz'), '... FooRole does have the baz attribute');
65 $foo_role->get_attribute('baz'),
67 '... got the correct description of the baz attribute');
71 ok($foo_role->has_method_modifier('before' => 'boo'), '... now we have a boo:before modifier');
72 is($foo_role->get_method_modifier('before' => 'boo')->(),
73 "FooRole::boo:before",
74 '... got the right method back');
77 [ $foo_role->get_method_modifier_list('before') ],
79 '... got the right list of before method modifiers');