remove trailing whitespace
[gitmo/Moose.git] / t / 300_immutable / 002_apply_roles_to_immutable.t
CommitLineData
d9bb6c63 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
7ff56534 6use Test::More tests => 4;
d9bb6c63 7use 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
30my $foo = Foo->new;
31isa_ok($foo, 'Foo');
32
33is($foo->baz, 'Foo::baz', '... got the right value');
34
35lives_ok {
36 My::Role->meta->apply($foo)
37} '... successfully applied the role to immutable instance';
38
39is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value');
40
41