X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100_bugs%2F024_anon_method_metaclass.t;h=01c52851cd87394eca2784abe93ccd850dda43ae;hb=34d6d196372ac514abfe975cef15e8afd0af04c4;hp=2b97cc822ebc98dbcf65edf11009c6bcd4e515c1;hpb=2de3231bf09248102e1e2afa8a272a1a6a793455;p=gitmo%2FMoose.git diff --git a/t/100_bugs/024_anon_method_metaclass.t b/t/100_bugs/024_anon_method_metaclass.t index 2b97cc8..01c5285 100644 --- a/t/100_bugs/024_anon_method_metaclass.t +++ b/t/100_bugs/024_anon_method_metaclass.t @@ -1,14 +1,16 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More; -do { +{ package Ball; use Moose; +} +{ package Arbitrary::Roll; use Moose::Role; -}; +} my $method_meta = Moose::Meta::Class->create_anon_class( superclasses => ['Moose::Meta::Method'], @@ -18,25 +20,31 @@ my $method_meta = Moose::Meta::Class->create_anon_class( # For comparing identity without actually keeping $original_meta around my $original_meta = "$method_meta"; -my $method_class = $method_meta->name; +my $method_class = $method_meta->name; my $method_object = $method_class->wrap( - sub { 'ok' }, + sub {'ok'}, associated_metaclass => Ball->meta, package_name => 'Ball', name => 'bounce', ); -Ball->meta->add_method(bounce => $method_object); +Ball->meta->add_method( bounce => $method_object ); -for (1, 2) { - is(Ball->bounce, 'ok', "method still exists on Ball"); - is(Ball->meta->get_method('bounce')->meta->name, $method_class, "method's package still exists"); - is(Ball->meta->get_method('bounce')->meta . '', $original_meta, "method's metaclass still exists"); - ok(Ball->meta->get_method('bounce')->meta->does_role('Arbitrary::Roll'), "method still does Arbitrary::Roll"); +for ( 1, 2 ) { + is( Ball->bounce, 'ok', "method still exists on Ball" ); + is( Ball->meta->get_method('bounce')->meta->name, $method_class, + "method's package still exists" ); - diag 'undef $method_meta' if $method_meta; - undef $method_meta; -}; + is( Ball->meta->get_method('bounce'), $method_object, + 'original method object is preserved' ); + + is( Ball->meta->get_method('bounce')->meta . '', $original_meta, + "method's metaclass still exists" ); + ok( Ball->meta->get_method('bounce')->meta->does_role('Arbitrary::Roll'), + "method still does Arbitrary::Roll" ); + undef $method_meta; +} +done_testing;