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;
10 $TODO = q{Mouse is not yet completed};
13 use Mouse::Meta::Role;
14 use Mouse::Util::TypeConstraints ();
19 our $VERSION = '0.01';
21 sub foo { 'FooRole::foo' }
24 my $foo_role = Mouse::Meta::Role->initialize('FooRole');
25 isa_ok($foo_role, 'Mouse::Meta::Role');
26 isa_ok($foo_role, 'Mouse::Meta::Module');
28 is($foo_role->name, 'FooRole', '... got the right name of FooRole');
29 is($foo_role->version, '0.01', '... got the right version of FooRole');
33 ok($foo_role->has_method('foo'), '... FooRole has the foo method');
34 is($foo_role->get_method('foo')->body, \&FooRole::foo, '... FooRole got the foo method');
36 isa_ok($foo_role->get_method('foo'), 'Mouse::Meta::Role::Method');
39 [ $foo_role->get_method_list() ],
41 '... got the right method list');
46 [ $foo_role->get_attribute_list() ],
48 '... got the right attribute list');
50 ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute');
53 $foo_role->add_attribute('bar' => (is => 'rw', isa => 'Foo'));
54 } '... added the bar attribute okay';
57 [ $foo_role->get_attribute_list() ],
59 '... got the right attribute list');
61 ok($foo_role->has_attribute('bar'), '... FooRole does have the bar attribute');
63 my $bar = $foo_role->get_attribute('bar');
64 is_deeply( $bar->original_options, { is => 'rw', isa => 'Foo' },
65 'original options for bar attribute' );
66 my $bar_for_class = $bar->attribute_for_class('Mouse::Meta::Attribute');
68 $bar_for_class->type_constraint,
69 Mouse::Util::TypeConstraints::class_type('Foo'),
70 'bar has a Foo class type'
74 $foo_role->add_attribute('baz' => (is => 'ro'));
75 } '... added the baz attribute okay';
78 [ sort $foo_role->get_attribute_list() ],
80 '... got the right attribute list');
82 ok($foo_role->has_attribute('baz'), '... FooRole does have the baz attribute');
84 my $baz = $foo_role->get_attribute('baz');
85 is_deeply( $baz->original_options, { is => 'ro' },
86 'original options for baz attribute' );
89 $foo_role->remove_attribute('bar');
90 } '... removed the bar attribute okay';
93 [ $foo_role->get_attribute_list() ],
95 '... got the right attribute list');
97 ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute');
98 ok($foo_role->has_attribute('baz'), '... FooRole does still have the baz attribute');
102 ok(!$foo_role->has_before_method_modifiers('boo'), '... no boo:before modifier');
104 my $method = sub { "FooRole::boo:before" };
106 $foo_role->add_before_method_modifier('boo' => $method);
107 } '... added a method modifier okay';
109 ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier');
110 is(($foo_role->get_before_method_modifiers('boo'))[0], $method, '... got the right method back');
113 [ $foo_role->get_method_modifier_list('before') ],
115 '... got the right list of before method modifiers');