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