X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=t%2F100_bugs%2F020_super_recursion.t;fp=t%2F100_bugs%2F020_super_recursion.t;h=ff691f9bbdb79a374ac6b29bfd2e6b40bb225264;hp=0000000000000000000000000000000000000000;hb=4c98ebb0cca8d5d49d3a91eaf735f9861d00ccb0;hpb=ad20156284763b7d6019af2279f24e1af097f3be diff --git a/t/100_bugs/020_super_recursion.t b/t/100_bugs/020_super_recursion.t new file mode 100644 index 0000000..ff691f9 --- /dev/null +++ b/t/100_bugs/020_super_recursion.t @@ -0,0 +1,67 @@ +use strict; +use warnings; + +use Test::More tests => 3; + +{ + package A; + use Mouse; + + sub foo { + ::BAIL_OUT('A::foo called twice') if $main::seen{'A::foo'}++; + return 'a'; + } + + sub bar { + ::BAIL_OUT('A::bar called twice') if $main::seen{'A::bar'}++; + return 'a'; + } + + sub baz { + ::BAIL_OUT('A::baz called twice') if $main::seen{'A::baz'}++; + return 'a'; + } +} + +{ + package B; + use Mouse; + extends qw(A); + + sub foo { + ::BAIL_OUT('B::foo called twice') if $main::seen{'B::foo'}++; + return 'b' . super(); + } + + sub bar { + ::BAIL_OUT('B::bar called twice') if $main::seen{'B::bar'}++; + return 'b' . ( super() || '' ); + } + + override baz => sub { + ::BAIL_OUT('B::baz called twice') if $main::seen{'B::baz'}++; + return 'b' . super(); + }; +} + +{ + package C; + use Mouse; + extends qw(B); + + sub foo { return 'c' . ( super() || '' ) } + + override bar => sub { + ::BAIL_OUT('C::bar called twice') if $main::seen{'C::bar'}++; + return 'c' . super(); + }; + + override baz => sub { + ::BAIL_OUT('C::baz called twice') if $main::seen{'C::baz'}++; + return 'c' . super(); + }; +} + +is( C->new->foo, 'c' ); +is( C->new->bar, 'cb' ); +is( C->new->baz, 'cba' );