Changelogging
[gitmo/Mouse.git] / t / 010_basics / 018_methods.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
60ad2cb7 5
6use strict;
7use warnings;
8
fde8e43f 9use Test::More;
60ad2cb7 10
11
12my $test1 = Mouse::Meta::Class->create_anon_class;
13$test1->add_method( 'foo1', sub { } );
14
15my $t1 = $test1->new_object;
16my $t1_am = $t1->meta->get_method('foo1')->associated_metaclass;
17
18ok( $t1_am, 'associated_metaclass is defined' );
19
20isa_ok(
21 $t1_am, 'Mouse::Meta::Class',
22 'associated_metaclass is correct class'
23);
24
25like( $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
36my $t2 = Test2->new;
37my $t2_am = $t2->meta->get_method('foo2')->associated_metaclass;
38
39ok( $t2_am, 'associated_metaclass is defined' );
40
41isa_ok(
42 $t2_am, 'Mouse::Meta::Class',
43 'associated_metaclass is correct class'
44);
45
46is( $t2_am->name(), 'Test2',
47 'associated_metaclass->name is Test2' );
fde8e43f 48
49done_testing;