Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 020_super_recursion.t
CommitLineData
4c98ebb0 1use strict;
ee5e6a03 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
4c98ebb0 5use warnings;
6
ee5e6a03 7use Test::More;
4c98ebb0 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
68is( C->new->foo, 'c' );
69is( C->new->bar, 'cb' );
70is( C->new->baz, 'cba' );
ee5e6a03 71
72done_testing;