6 use Test::More no_plan => 1;
10 use_ok('Class::MOP::SafeMixin');
18 sub MODIFY_CODE_ATTRIBUTES {
19 my ($class, $code, @attrs) = @_;
20 ::diag join ", " => $code, "Attrs: ", @attrs;
21 $cache{$code} = $attrs[0];
25 sub FETCH_CODE_ATTRIBUTES { $cache{$_[1]} }
27 sub foo : before { 'FooMixin::foo::before -> ' }
28 sub bar : after { ' -> FooMixin::bar::after' }
31 my ($self, @args) = @_;
32 'FooMixin::baz::around(' . $self->$method(@args) . ')';
36 use metaclass 'Class::MOP::SafeMixin';
38 Foo->meta->mixin('FooMixin');
40 sub new { (shift)->meta->new_object(@_) }
42 sub foo { 'Foo::foo' }
43 sub bar { 'Foo::bar' }
44 sub baz { 'Foo::baz' }
47 diag attributes::get(\&FooMixin::foo) . "\n";
52 is($foo->foo(), 'FooMixin::foo::before -> Foo::foo', '... before method worked');
53 is($foo->bar(), 'Foo::bar -> FooMixin::bar::after', '... after method worked');
54 is($foo->baz(), 'FooMixin::baz::around(Foo::baz)', '... around method worked');