s/make_immutable/metaclass->make_immutable/
[gitmo/Moose.git] / t / 300_immutable / 002_apply_roles_to_immutable.t
CommitLineData
d9bb6c63 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More no_plan => 1;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose');
11}
12
13{
14 package My::Role;
15 use Moose::Role;
16
17 around 'baz' => sub {
18 my $next = shift;
19 'My::Role::baz(' . $next->(@_) . ')';
20 };
21}
22
23{
24 package Foo;
25 use Moose;
26
27 sub baz { 'Foo::baz' }
28
f02c03d6 29 metaclass->make_immutable(debug => 0);
d9bb6c63 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
43