Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 300_immutable / 002_apply_roles_to_immutable.t
1 #!/usr/bin/perl
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;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
10 use Test::Exception;
11
12
13 {
14     package My::Role;
15     use Mouse::Role;
16
17     around 'baz' => sub {
18         my $next = shift;
19         'My::Role::baz(' . $next->(@_) . ')';
20     };
21 }
22
23 {
24     package Foo;
25     use Mouse;
26
27     sub baz { 'Foo::baz' }
28
29     __PACKAGE__->meta->make_immutable(debug => 0);
30 }
31
32 my $foo = Foo->new;
33 isa_ok($foo, 'Foo');
34
35 is($foo->baz, 'Foo::baz', '... got the right value');
36
37 lives_ok {
38     My::Role->meta->apply($foo)
39 } '... successfully applied the role to immutable instance';
40
41 is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value');
42
43 done_testing;