From: Chris Prather Date: Sun, 11 Jan 2009 23:45:01 +0000 (+0000) Subject: add tests for recursion in super() X-Git-Tag: 0.65~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=085c56c26b79981b8eed77e8c5523c346511ed29;p=gitmo%2FMoose.git add tests for recursion in super() --- diff --git a/t/100_bugs/020_super_recursion.t b/t/100_bugs/020_super_recursion.t new file mode 100644 index 0000000..89b355c --- /dev/null +++ b/t/100_bugs/020_super_recursion.t @@ -0,0 +1,34 @@ +#!/usr/bin/env perl -l +use Test::More qw(no_plan); +our $seen; + +package A; +use Moose; + +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 Moose; +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 Moose; +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() }; + + +package main; + +is(C->new->foo, 'c'); +is(C->new->bar, 'cb'); +is(C->new->baz, 'cba');