Commit | Line | Data |
---|---|---|
d9bb6c63 | 1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
7ff56534 | 6 | use Test::More tests => 4; |
d9bb6c63 | 7 | use Test::Exception; |
8 | ||
7ff56534 | 9 | |
d9bb6c63 | 10 | |
11 | { | |
12 | package My::Role; | |
13 | use Moose::Role; | |
d03bd989 | 14 | |
15 | around 'baz' => sub { | |
d9bb6c63 | 16 | my $next = shift; |
17 | 'My::Role::baz(' . $next->(@_) . ')'; | |
18 | }; | |
19 | } | |
20 | ||
21 | { | |
22 | package Foo; | |
23 | use Moose; | |
d03bd989 | 24 | |
d9bb6c63 | 25 | sub baz { 'Foo::baz' } |
d03bd989 | 26 | |
5a3217de | 27 | __PACKAGE__->meta->make_immutable(debug => 0); |
d9bb6c63 | 28 | } |
29 | ||
30 | my $foo = Foo->new; | |
31 | isa_ok($foo, 'Foo'); | |
32 | ||
33 | is($foo->baz, 'Foo::baz', '... got the right value'); | |
34 | ||
35 | lives_ok { | |
36 | My::Role->meta->apply($foo) | |
37 | } '... successfully applied the role to immutable instance'; | |
38 | ||
39 | is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value'); | |
40 | ||
41 |