Commit | Line | Data |
60ad2cb7 |
1 | #!/usr/bin/perl |
fde8e43f |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
60ad2cb7 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
fde8e43f |
9 | use Test::More; |
60ad2cb7 |
10 | |
11 | |
12 | my $test1 = Mouse::Meta::Class->create_anon_class; |
13 | $test1->add_method( 'foo1', sub { } ); |
14 | |
15 | my $t1 = $test1->new_object; |
16 | my $t1_am = $t1->meta->get_method('foo1')->associated_metaclass; |
17 | |
18 | ok( $t1_am, 'associated_metaclass is defined' ); |
19 | |
20 | isa_ok( |
21 | $t1_am, 'Mouse::Meta::Class', |
22 | 'associated_metaclass is correct class' |
23 | ); |
24 | |
25 | like( $t1_am->name(), qr/::__ANON__::/, |
26 | 'associated_metaclass->name looks like an anonymous class' ); |
27 | |
28 | { |
29 | package Test2; |
30 | |
31 | use Mouse; |
32 | |
33 | sub foo2 { } |
34 | } |
35 | |
36 | my $t2 = Test2->new; |
37 | my $t2_am = $t2->meta->get_method('foo2')->associated_metaclass; |
38 | |
39 | ok( $t2_am, 'associated_metaclass is defined' ); |
40 | |
41 | isa_ok( |
42 | $t2_am, 'Mouse::Meta::Class', |
43 | 'associated_metaclass is correct class' |
44 | ); |
45 | |
46 | is( $t2_am->name(), 'Test2', |
47 | 'associated_metaclass->name is Test2' ); |
fde8e43f |
48 | |
49 | done_testing; |