6 use Test::More tests => 23;
10 use_ok('Moose::Meta::Role');
16 our $VERSION = '0.01';
18 sub foo { 'FooRole::foo' }
21 my $foo_role = Moose::Meta::Role->initialize('FooRole');
22 isa_ok($foo_role, 'Moose::Meta::Role');
23 isa_ok($foo_role, 'Class::MOP::Module');
25 is($foo_role->name, 'FooRole', '... got the right name of FooRole');
26 is($foo_role->version, '0.01', '... got the right version of FooRole');
30 ok($foo_role->has_method('foo'), '... FooRole has the foo method');
31 is($foo_role->get_method('foo'), \&FooRole::foo, '... FooRole got the foo method');
33 isa_ok($foo_role->get_method('foo'), 'Moose::Meta::Role::Method');
36 [ $foo_role->get_method_list() ],
38 '... got the right method list');
43 [ $foo_role->get_attribute_list() ],
45 '... got the right attribute list');
47 ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute');
50 $foo_role->add_attribute('bar' => (is => 'rw', isa => 'Foo'));
51 } '... added the bar attribute okay';
54 [ $foo_role->get_attribute_list() ],
56 '... got the right attribute list');
58 ok($foo_role->has_attribute('bar'), '... FooRole does have the bar attribute');
61 $foo_role->get_attribute('bar'),
62 { is => 'rw', isa => 'Foo' },
63 '... got the correct description of the bar attribute');
66 $foo_role->add_attribute('baz' => (is => 'ro'));
67 } '... added the baz attribute okay';
70 [ sort $foo_role->get_attribute_list() ],
72 '... got the right attribute list');
74 ok($foo_role->has_attribute('baz'), '... FooRole does have the baz attribute');
77 $foo_role->get_attribute('baz'),
79 '... got the correct description of the baz attribute');
82 $foo_role->remove_attribute('bar');
83 } '... removed the bar attribute okay';
86 [ $foo_role->get_attribute_list() ],
88 '... got the right attribute list');
90 ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute');
91 ok($foo_role->has_attribute('baz'), '... FooRole does still have the baz attribute');