No need to document an internals change
[gitmo/Moose.git] / t / 100_bugs / 024_anon_method_metaclass.t
CommitLineData
2de3231b 1use strict;
2use warnings;
3use Test::More tests => 8;
4
5do {
6 package Ball;
7 use Moose;
8
9 package Arbitrary::Roll;
10 use Moose::Role;
11};
12
13my $method_meta = Moose::Meta::Class->create_anon_class(
14 superclasses => ['Moose::Meta::Method'],
15 roles => ['Arbitrary::Roll'],
16);
17
18# For comparing identity without actually keeping $original_meta around
19my $original_meta = "$method_meta";
20
21my $method_class = $method_meta->name;
22
23my $method_object = $method_class->wrap(
24 sub { 'ok' },
25 associated_metaclass => Ball->meta,
26 package_name => 'Ball',
27 name => 'bounce',
28);
29
30Ball->meta->add_method(bounce => $method_object);
31
32for (1, 2) {
33 is(Ball->bounce, 'ok', "method still exists on Ball");
34 is(Ball->meta->get_method('bounce')->meta->name, $method_class, "method's package still exists");
8eaf26e6 35
36 local $TODO = "method seems to be reinitialized" if !$method_meta;
37
2de3231b 38 is(Ball->meta->get_method('bounce')->meta . '', $original_meta, "method's metaclass still exists");
39 ok(Ball->meta->get_method('bounce')->meta->does_role('Arbitrary::Roll'), "method still does Arbitrary::Roll");
40
2de3231b 41 undef $method_meta;
42};
43
44