Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 010_basics / 018_methods.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
9864f0e4 6use Test::More tests => 6;
60ad2cb7 7
8
9my $test1 = Mouse::Meta::Class->create_anon_class;
10$test1->add_method( 'foo1', sub { } );
11
12my $t1 = $test1->new_object;
13my $t1_am = $t1->meta->get_method('foo1')->associated_metaclass;
14
15ok( $t1_am, 'associated_metaclass is defined' );
16
17isa_ok(
18 $t1_am, 'Mouse::Meta::Class',
19 'associated_metaclass is correct class'
20);
21
22like( $t1_am->name(), qr/::__ANON__::/,
23 'associated_metaclass->name looks like an anonymous class' );
24
25{
26 package Test2;
27
28 use Mouse;
29
30 sub foo2 { }
31}
32
33my $t2 = Test2->new;
34my $t2_am = $t2->meta->get_method('foo2')->associated_metaclass;
35
36ok( $t2_am, 'associated_metaclass is defined' );
37
38isa_ok(
39 $t2_am, 'Mouse::Meta::Class',
40 'associated_metaclass is correct class'
41);
42
43is( $t2_am->name(), 'Test2',
44 'associated_metaclass->name is Test2' );