Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 300_immutable / 002_apply_roles_to_immutable.t
CommitLineData
16504b15 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!!!
4use t::lib::MooseCompat;
5
6use strict;
7use warnings;
8
9use Test::More;
10use 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
32my $foo = Foo->new;
33isa_ok($foo, 'Foo');
34
35is($foo->baz, 'Foo::baz', '... got the right value');
36
37lives_ok {
38 My::Role->meta->apply($foo)
39} '... successfully applied the role to immutable instance';
40
41is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value');
42
43done_testing;