12 The following class hierarhcy is very contrived
13 and totally horrid (it won't work under C3 even),
14 but it tests a number of aspect of this module.
16 A more real-world example would be a nice addition :)
23 sub BUILD { 'Foo::BUILD' }
24 sub foo { 'Foo::foo' }
29 sub BUILD { 'Bar::BUILD' }
30 sub bar { 'Bar::bar' }
35 sub baz { 'Baz::baz' }
36 sub foo { 'Baz::foo' }
39 our @ISA = ('Foo', 'Bar');
41 sub BUILD { 'Foo::Bar::BUILD' }
42 sub foobar { 'Foo::Bar::foobar' }
44 package Foo::Bar::Baz;
45 our @ISA = ('Foo', 'Bar', 'Baz');
47 sub BUILD { 'Foo::Bar::Baz::BUILD' }
48 sub bar { 'Foo::Bar::Baz::bar' }
49 sub foobarbaz { 'Foo::Bar::Baz::foobarbaz' }
52 ok(!defined(Class::MOP::Class->initialize('Foo')->find_next_method_by_name('BUILD')),
53 '... Foo::BUILD has not next method');
55 is(Class::MOP::Class->initialize('Bar')->find_next_method_by_name('BUILD'),
56 Class::MOP::Class->initialize('Foo')->get_method('BUILD'),
57 '... Bar::BUILD does have a next method');
59 is(Class::MOP::Class->initialize('Baz')->find_next_method_by_name('BUILD'),
60 Class::MOP::Class->initialize('Bar')->get_method('BUILD'),
61 '... Baz->BUILD does have a next method');
63 is(Class::MOP::Class->initialize('Foo::Bar')->find_next_method_by_name('BUILD'),
64 Class::MOP::Class->initialize('Foo')->get_method('BUILD'),
65 '... Foo::Bar->BUILD does have a next method');
67 is(Class::MOP::Class->initialize('Foo::Bar::Baz')->find_next_method_by_name('BUILD'),
68 Class::MOP::Class->initialize('Foo')->get_method('BUILD'),
69 '... Foo::Bar::Baz->BUILD does have a next method');
73 sort { $a->name cmp $b->name }
74 grep { $_->package_name ne 'UNIVERSAL' }
75 Class::MOP::Class->initialize('Foo')->get_all_methods()
78 Class::MOP::Class->initialize('Foo')->get_method('BUILD') ,
79 Class::MOP::Class->initialize('Foo')->get_method('foo'),
81 '... got the right list of applicable methods for Foo');
85 sort { $a->name cmp $b->name }
86 grep { $_->package_name ne 'UNIVERSAL' }
87 Class::MOP::Class->initialize('Bar')->get_all_methods()
90 Class::MOP::Class->initialize('Bar')->get_method('BUILD'),
91 Class::MOP::Class->initialize('Bar')->get_method('bar'),
92 Class::MOP::Class->initialize('Foo')->get_method('foo'),
94 '... got the right list of applicable methods for Bar');
99 sort { $a->name cmp $b->name }
100 grep { $_->package_name ne 'UNIVERSAL' }
101 Class::MOP::Class->initialize('Baz')->get_all_methods()
104 Class::MOP::Class->initialize('Bar')->get_method('BUILD'),
105 Class::MOP::Class->initialize('Bar')->get_method('bar'),
106 Class::MOP::Class->initialize('Baz')->get_method('baz'),
107 Class::MOP::Class->initialize('Baz')->get_method('foo'),
109 '... got the right list of applicable methods for Baz');
113 sort { $a->name cmp $b->name }
114 grep { $_->package_name ne 'UNIVERSAL' }
115 Class::MOP::Class->initialize('Foo::Bar')->get_all_methods()
118 Class::MOP::Class->initialize('Foo::Bar')->get_method('BUILD'),
119 Class::MOP::Class->initialize('Bar')->get_method('bar'),
120 Class::MOP::Class->initialize('Foo')->get_method('foo'),
121 Class::MOP::Class->initialize('Foo::Bar')->get_method('foobar'),
123 '... got the right list of applicable methods for Foo::Bar');
125 ## find_all_methods_by_name
128 [ Class::MOP::Class->initialize('Foo::Bar')->find_all_methods_by_name('BUILD') ],
133 code => Class::MOP::Class->initialize('Foo::Bar')->get_method('BUILD')
138 code => Class::MOP::Class->initialize('Foo')->get_method('BUILD')
143 code => Class::MOP::Class->initialize('Bar')->get_method('BUILD')
146 '... got the right list of BUILD methods for Foo::Bar');
149 [ Class::MOP::Class->initialize('Foo::Bar::Baz')->find_all_methods_by_name('BUILD') ],
153 class => 'Foo::Bar::Baz',
154 code => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('BUILD')
159 code => Class::MOP::Class->initialize('Foo')->get_method('BUILD')
164 code => Class::MOP::Class->initialize('Bar')->get_method('BUILD')
167 '... got the right list of BUILD methods for Foo::Bar::Baz');