Implement strict constructors, which will warn unkown constructor arguments
[gitmo/Mouse.git] / t / 100_bugs / 020_super_recursion.t
CommitLineData
4c98ebb0 1use strict;
2use warnings;
3
4use Test::More tests => 3;
5
6{
7 package A;
8 use Mouse;
9
10 sub foo {
11 ::BAIL_OUT('A::foo called twice') if $main::seen{'A::foo'}++;
12 return 'a';
13 }
14
15 sub bar {
16 ::BAIL_OUT('A::bar called twice') if $main::seen{'A::bar'}++;
17 return 'a';
18 }
19
20 sub baz {
21 ::BAIL_OUT('A::baz called twice') if $main::seen{'A::baz'}++;
22 return 'a';
23 }
24}
25
26{
27 package B;
28 use Mouse;
29 extends qw(A);
30
31 sub foo {
32 ::BAIL_OUT('B::foo called twice') if $main::seen{'B::foo'}++;
33 return 'b' . super();
34 }
35
36 sub bar {
37 ::BAIL_OUT('B::bar called twice') if $main::seen{'B::bar'}++;
38 return 'b' . ( super() || '' );
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{
48 package C;
49 use Mouse;
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
65is( C->new->foo, 'c' );
66is( C->new->bar, 'cb' );
67is( C->new->baz, 'cba' );