Merge branch 'stable'
[gitmo/Class-MOP.git] / t / 305_RT_41255.t
CommitLineData
3d25b8ec 1use strict;
86a4d873 2use Test::More;
871e9eb5 3use Test::Fatal;
3d25b8ec 4
5use Class::MOP;
6
7{
18591857 8 package BaseClass;
3d25b8ec 9 sub m1 { 1 }
10 sub m2 { 2 }
11 sub m3 { 3 }
12 sub m4 { 4 }
13 sub m5 { 5 }
14
15 package Derived;
18591857 16 use base qw(BaseClass);
3d25b8ec 17
18 sub m1;
19 sub m2 ();
20 sub m3 :method;
21 sub m4; m4() if 0;
22 sub m5; our $m5;;
23}
24
25my $meta = Class::MOP::Class->initialize('Derived');
26my %methods = map { $_ => $meta->find_method_by_name($_) } 'm1' .. 'm5';
27
28while (my ($name, $meta_method) = each %methods) {
29 is $meta_method->fully_qualified_name, "Derived::${name}";
871e9eb5 30 like( exception { $meta_method->execute }, qr/Undefined subroutine .* called at/ );
3d25b8ec 31}
e24c686f 32
33{
34 package Derived;
35 eval <<'EOC';
36
37 sub m1 { 'affe' }
38 sub m2 () { 'apan' }
39 sub m3 :method { 'tiger' }
40 sub m4 { 'birne' }
41 sub m5 { 'apfel' }
42
43EOC
44}
45
46while (my ($name, $meta_method) = each %methods) {
47 is $meta_method->fully_qualified_name, "Derived::${name}";
871e9eb5 48 is( exception { $meta_method->execute }, undef );
e24c686f 49}
86a4d873 50
51done_testing;