X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F300_immutable%2F002_apply_roles_to_immutable.t;fp=t%2F300_immutable%2F002_apply_roles_to_immutable.t;h=e003a42d635c0d1896f356d43695b72d98117b02;hb=fde8e43f95fe996fbc2a778aa259feeb04552171;hp=0000000000000000000000000000000000000000;hpb=0bdc9d38dfd3de07aad929f6629f8fa65d434c27;p=gitmo%2FMouse.git diff --git a/t/300_immutable/002_apply_roles_to_immutable.t b/t/300_immutable/002_apply_roles_to_immutable.t new file mode 100644 index 0000000..e003a42 --- /dev/null +++ b/t/300_immutable/002_apply_roles_to_immutable.t @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +use Test::Exception; + + +{ + package My::Role; + use Mouse::Role; + + around 'baz' => sub { + my $next = shift; + 'My::Role::baz(' . $next->(@_) . ')'; + }; +} + +{ + package Foo; + use Mouse; + + sub baz { 'Foo::baz' } + + __PACKAGE__->meta->make_immutable(debug => 0); +} + +my $foo = Foo->new; +isa_ok($foo, 'Foo'); + +is($foo->baz, 'Foo::baz', '... got the right value'); + +lives_ok { + My::Role->meta->apply($foo) +} '... successfully applied the role to immutable instance'; + +is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value'); + +done_testing;