Revert autogenerated tests. Tests should not changed radically.
[gitmo/Mouse.git] / t / 100_bugs / failing / 024_anon_method_metaclass.t
CommitLineData
4c98ebb0 1use strict;
2use warnings;
9864f0e4 3use Test::More tests => 10;
4c98ebb0 4
5{
6 package Ball;
7 use Mouse;
8}
9
10{
11 package Arbitrary::Roll;
12 use Mouse::Role;
13}
14
15my $method_meta = Mouse::Meta::Class->create_anon_class(
16 superclasses => ['Mouse::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
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" );
38
39 is( Ball->meta->get_method('bounce'), $method_object,
40 'original method object is preserved' );
41
42 is( Ball->meta->get_method('bounce')->meta . '', $original_meta,
43 "method's metaclass still exists" );
44 ok( Ball->meta->get_method('bounce')->meta->does_role('Arbitrary::Roll'),
45 "method still does Arbitrary::Roll" );
46
47 undef $method_meta;
48}