summaryrefslogtreecommitdiff
path: root/t/bugs/anon_method_metaclass.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
commit5ac2026f7eed78958d69d051e7a8e993dcf51205 (patch)
tree298c3d2f08bdfe5689998b11892d72a897985be1 /t/bugs/anon_method_metaclass.t
downloadMoose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz
Diffstat (limited to 't/bugs/anon_method_metaclass.t')
-rw-r--r--t/bugs/anon_method_metaclass.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/bugs/anon_method_metaclass.t b/t/bugs/anon_method_metaclass.t
new file mode 100644
index 0000000..01c5285
--- /dev/null
+++ b/t/bugs/anon_method_metaclass.t
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+use Test::More;
+
+{
+ package Ball;
+ use Moose;
+}
+
+{
+ package Arbitrary::Roll;
+ use Moose::Role;
+}
+
+my $method_meta = Moose::Meta::Class->create_anon_class(
+ superclasses => ['Moose::Meta::Method'],
+ roles => ['Arbitrary::Roll'],
+);
+
+# For comparing identity without actually keeping $original_meta around
+my $original_meta = "$method_meta";
+
+my $method_class = $method_meta->name;
+
+my $method_object = $method_class->wrap(
+ sub {'ok'},
+ associated_metaclass => Ball->meta,
+ package_name => 'Ball',
+ name => 'bounce',
+);
+
+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'), $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;