Commit | Line | Data |
---|---|---|
7ed11811 | 1 | use strict; |
2 | use warnings; | |
085c56c2 | 3 | |
a28e50e4 | 4 | use Test::More; |
085c56c2 | 5 | |
7ed11811 | 6 | { |
7ed11811 | 7 | package A; |
8 | use Moose; | |
085c56c2 | 9 | |
7ed11811 | 10 | sub foo { |
11 | ::BAIL_OUT('A::foo called twice') if $main::seen{'A::foo'}++; | |
12 | return 'a'; | |
13 | } | |
085c56c2 | 14 | |
7ed11811 | 15 | sub bar { |
16 | ::BAIL_OUT('A::bar called twice') if $main::seen{'A::bar'}++; | |
17 | return 'a'; | |
18 | } | |
085c56c2 | 19 | |
7ed11811 | 20 | sub baz { |
21 | ::BAIL_OUT('A::baz called twice') if $main::seen{'A::baz'}++; | |
22 | return 'a'; | |
23 | } | |
24 | } | |
085c56c2 | 25 | |
7ed11811 | 26 | { |
7ed11811 | 27 | package B; |
28 | use Moose; | |
29 | extends qw(A); | |
085c56c2 | 30 | |
7ed11811 | 31 | sub foo { |
32 | ::BAIL_OUT('B::foo called twice') if $main::seen{'B::foo'}++; | |
33 | return 'b' . super(); | |
34 | } | |
085c56c2 | 35 | |
7ed11811 | 36 | sub bar { |
37 | ::BAIL_OUT('B::bar called twice') if $main::seen{'B::bar'}++; | |
3fe35134 | 38 | return 'b' . ( super() || '' ); |
7ed11811 | 39 | } |
40 | ||
41 | override baz => sub { | |
42 | ::BAIL_OUT('B::baz called twice') if $main::seen{'B::baz'}++; | |
43 | return 'b' . super(); | |
44 | }; | |
45 | } | |
46 | ||
47 | { | |
7ed11811 | 48 | package C; |
49 | use Moose; | |
50 | extends qw(B); | |
51 | ||
52 | sub foo { return 'c' . ( super() || '' ) } | |
53 | ||
54 | override bar => sub { | |
55 | ::BAIL_OUT('C::bar called twice') if $main::seen{'C::bar'}++; | |
56 | return 'c' . super(); | |
57 | }; | |
58 | ||
59 | override baz => sub { | |
60 | ::BAIL_OUT('C::baz called twice') if $main::seen{'C::baz'}++; | |
61 | return 'c' . super(); | |
62 | }; | |
63 | } | |
64 | ||
65 | is( C->new->foo, 'c' ); | |
66 | is( C->new->bar, 'cb' ); | |
67 | is( C->new->baz, 'cba' ); | |
a28e50e4 | 68 | |
69 | done_testing; |