Commit | Line | Data |
b6fe348f |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
159da176 |
6 | use Test::More tests => 16; |
b6fe348f |
7 | |
8 | BEGIN { |
9 | use_ok('Moose'); |
10 | } |
11 | |
12 | { |
13 | package Foo; |
14 | use strict; |
15 | use warnings; |
16 | use Moose; |
17 | |
18 | sub foo { 'Foo::foo' } |
19 | sub bar { 'Foo::bar' } |
20 | sub baz { 'Foo::baz' } |
21 | |
22 | package Bar; |
23 | use strict; |
24 | use warnings; |
25 | use Moose; |
26 | |
27 | extends 'Foo'; |
28 | |
29 | override bar => sub { 'Bar::bar -> ' . super() }; |
30 | |
31 | package Baz; |
32 | use strict; |
33 | use warnings; |
34 | use Moose; |
35 | |
36 | extends 'Bar'; |
37 | |
159da176 |
38 | override bar => sub { 'Baz::bar -> ' . super() }; |
b6fe348f |
39 | override baz => sub { 'Baz::baz -> ' . super() }; |
40 | } |
41 | |
42 | my $baz = Baz->new(); |
43 | isa_ok($baz, 'Baz'); |
44 | isa_ok($baz, 'Bar'); |
45 | isa_ok($baz, 'Foo'); |
46 | |
47 | is($baz->foo(), 'Foo::foo', '... got the right value from &foo'); |
159da176 |
48 | is($baz->bar(), 'Baz::bar -> Bar::bar -> Foo::bar', '... got the right value from &bar'); |
b6fe348f |
49 | is($baz->baz(), 'Baz::baz -> Foo::baz', '... got the right value from &baz'); |
159da176 |
50 | |
51 | my $bar = Bar->new(); |
52 | isa_ok($bar, 'Bar'); |
53 | isa_ok($bar, 'Foo'); |
54 | |
55 | is($bar->foo(), 'Foo::foo', '... got the right value from &foo'); |
56 | is($bar->bar(), 'Bar::bar -> Foo::bar', '... got the right value from &bar'); |
57 | is($bar->baz(), 'Foo::baz', '... got the right value from &baz'); |
58 | |
59 | my $foo = Foo->new(); |
60 | isa_ok($foo, 'Foo'); |
61 | |
62 | is($foo->foo(), 'Foo::foo', '... got the right value from &foo'); |
63 | is($foo->bar(), 'Foo::bar', '... got the right value from &bar'); |
64 | is($foo->baz(), 'Foo::baz', '... got the right value from &baz'); |