Commit | Line | Data |
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!!! |
4 | use t::lib::MooseCompat; |
60ad2cb7 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
fde8e43f |
9 | use Test::More; |
60ad2cb7 |
10 | use Test::Exception; |
11 | |
12 | |
60ad2cb7 |
13 | { |
14 | package Foo; |
15 | use Mouse; |
16 | |
17 | sub foo { 'Foo::foo' } |
18 | sub bar { 'Foo::bar' } |
19 | sub baz { 'Foo::baz' } |
20 | |
21 | package Bar; |
22 | use Mouse; |
23 | |
24 | extends 'Foo'; |
25 | |
26 | override bar => sub { 'Bar::bar -> ' . super() }; |
27 | |
28 | package Baz; |
29 | use Mouse; |
30 | |
31 | extends 'Bar'; |
32 | |
33 | override bar => sub { 'Baz::bar -> ' . super() }; |
34 | override baz => sub { 'Baz::baz -> ' . super() }; |
35 | |
36 | no Mouse; # ensure super() still works after unimport |
37 | } |
38 | |
39 | my $baz = Baz->new(); |
40 | isa_ok($baz, 'Baz'); |
41 | isa_ok($baz, 'Bar'); |
42 | isa_ok($baz, 'Foo'); |
43 | |
44 | is($baz->foo(), 'Foo::foo', '... got the right value from &foo'); |
45 | is($baz->bar(), 'Baz::bar -> Bar::bar -> Foo::bar', '... got the right value from &bar'); |
46 | is($baz->baz(), 'Baz::baz -> Foo::baz', '... got the right value from &baz'); |
47 | |
48 | my $bar = Bar->new(); |
49 | isa_ok($bar, 'Bar'); |
50 | isa_ok($bar, 'Foo'); |
51 | |
52 | is($bar->foo(), 'Foo::foo', '... got the right value from &foo'); |
53 | is($bar->bar(), 'Bar::bar -> Foo::bar', '... got the right value from &bar'); |
54 | is($bar->baz(), 'Foo::baz', '... got the right value from &baz'); |
55 | |
56 | my $foo = Foo->new(); |
57 | isa_ok($foo, 'Foo'); |
58 | |
59 | is($foo->foo(), 'Foo::foo', '... got the right value from &foo'); |
60 | is($foo->bar(), 'Foo::bar', '... got the right value from &bar'); |
61 | is($foo->baz(), 'Foo::baz', '... got the right value from &baz'); |
62 | |
63 | # some error cases |
64 | |
65 | { |
66 | package Bling; |
67 | use Mouse; |
68 | |
69 | sub bling { 'Bling::bling' } |
70 | |
71 | package Bling::Bling; |
72 | use Mouse; |
73 | |
74 | extends 'Bling'; |
75 | |
76 | sub bling { 'Bling::bling' } |
77 | |
78 | ::dies_ok { |
79 | override 'bling' => sub {}; |
80 | } '... cannot override a method which has a local equivalent'; |
81 | |
82 | } |
83 | |
fde8e43f |
84 | done_testing; |