Commit | Line | Data |
96245b5a |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
a28e50e4 |
6 | use Test::More; |
96245b5a |
7 | |
8 | |
9 | my $test1 = Moose::Meta::Class->create_anon_class; |
10 | $test1->add_method( 'foo1', sub { } ); |
11 | |
12 | my $t1 = $test1->new_object; |
13 | my $t1_am = $t1->meta->get_method('foo1')->associated_metaclass; |
19f02ab1 |
14 | |
96245b5a |
15 | ok( $t1_am, 'associated_metaclass is defined' ); |
19f02ab1 |
16 | |
96245b5a |
17 | isa_ok( |
18 | $t1_am, 'Moose::Meta::Class', |
19 | 'associated_metaclass is correct class' |
20 | ); |
21 | |
19f02ab1 |
22 | like( $t1_am->name(), qr/::__ANON__::/, |
23 | 'associated_metaclass->name looks like an anonymous class' ); |
24 | |
96245b5a |
25 | { |
96245b5a |
26 | package Test2; |
27 | |
28 | use Moose; |
29 | |
30 | sub foo2 { } |
31 | } |
32 | |
33 | my $t2 = Test2->new; |
34 | my $t2_am = $t2->meta->get_method('foo2')->associated_metaclass; |
19f02ab1 |
35 | |
96245b5a |
36 | ok( $t2_am, 'associated_metaclass is defined' ); |
37 | |
38 | isa_ok( |
39 | $t2_am, 'Moose::Meta::Class', |
40 | 'associated_metaclass is correct class' |
41 | ); |
19f02ab1 |
42 | |
43 | is( $t2_am->name(), 'Test2', |
44 | 'associated_metaclass->name is Test2' ); |
a28e50e4 |
45 | |
46 | done_testing; |