lib/Moose/Meta/Attribute/Native/Trait.pm: factor out some of the namespace resolution...
[gitmo/Moose.git] / t / immutable / apply_roles_to_immutable.t
CommitLineData
d9bb6c63 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
b10dde3a 7use Test::Fatal;
d9bb6c63 8
7ff56534 9
d9bb6c63 10{
11 package My::Role;
12 use Moose::Role;
d03bd989 13
14 around 'baz' => sub {
d9bb6c63 15 my $next = shift;
16 'My::Role::baz(' . $next->(@_) . ')';
17 };
18}
19
20{
21 package Foo;
22 use Moose;
d03bd989 23
d9bb6c63 24 sub baz { 'Foo::baz' }
d03bd989 25
9978e85e 26 __PACKAGE__->meta->make_immutable(debug => 0);
d9bb6c63 27}
28
29my $foo = Foo->new;
30isa_ok($foo, 'Foo');
31
32is($foo->baz, 'Foo::baz', '... got the right value');
33
b10dde3a 34is( exception {
d9bb6c63 35 My::Role->meta->apply($foo)
b10dde3a 36}, undef, '... successfully applied the role to immutable instance' );
d9bb6c63 37
38is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value');
39
a28e50e4 40done_testing;