Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 020_super_recursion.t
1 use strict;
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;
5 use warnings;
6
7 use Test::More;
8
9 {
10     package A;
11     use Mouse;
12
13     sub foo {
14         ::BAIL_OUT('A::foo called twice') if $main::seen{'A::foo'}++;
15         return 'a';
16     }
17
18     sub bar {
19         ::BAIL_OUT('A::bar called twice') if $main::seen{'A::bar'}++;
20         return 'a';
21     }
22
23     sub baz {
24         ::BAIL_OUT('A::baz called twice') if $main::seen{'A::baz'}++;
25         return 'a';
26     }
27 }
28
29 {
30     package B;
31     use Mouse;
32     extends qw(A);
33
34     sub foo {
35         ::BAIL_OUT('B::foo called twice') if $main::seen{'B::foo'}++;
36         return 'b' . super();
37     }
38
39     sub bar {
40         ::BAIL_OUT('B::bar called twice') if $main::seen{'B::bar'}++;
41         return 'b' . ( super() || '' );
42     }
43
44     override baz => sub {
45         ::BAIL_OUT('B::baz called twice') if $main::seen{'B::baz'}++;
46         return 'b' . super();
47     };
48 }
49
50 {
51     package C;
52     use Mouse;
53     extends qw(B);
54
55     sub foo { return 'c' . ( super() || '' ) }
56
57     override bar => sub {
58         ::BAIL_OUT('C::bar called twice') if $main::seen{'C::bar'}++;
59         return 'c' . super();
60     };
61
62     override baz => sub {
63         ::BAIL_OUT('C::baz called twice') if $main::seen{'C::baz'}++;
64         return 'c' . super();
65     };
66 }
67
68 is( C->new->foo, 'c' );
69 is( C->new->bar, 'cb' );
70 is( C->new->baz, 'cba' );
71
72 done_testing;