DEATH TO ALL zionist ELLIPSES
[gitmo/Moose.git] / t / 100_bugs / 009_augment_recursion_bug.t
CommitLineData
b468a3d3 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
7ff56534 6use Test::More tests => 3;
7
b468a3d3 8
b468a3d3 9
10{
11 package Foo;
12 use Moose;
13
14 sub foo { 'Foo::foo(' . (inner() || '') . ')' };
15
16 package Bar;
17 use Moose;
18
19 extends 'Foo';
20
21 package Baz;
22 use Moose;
23
24 extends 'Foo';
25
26 my $foo_call_counter;
27 augment 'foo' => sub {
28 die "infinite loop on Baz::foo" if $foo_call_counter++ > 1;
29 return 'Baz::foo and ' . Bar->new->foo;
30 };
31}
32
33my $baz = Baz->new();
34isa_ok($baz, 'Baz');
35isa_ok($baz, 'Foo');
36
37=pod
38
39When a subclass which augments foo(), calls a subclass which does not augment
40foo(), there is a chance for some confusion. If Moose does not realize that
6549b0d1 41Bar does not augment foo(), because it is in the call flow of Baz which does,
b468a3d3 42then we may have an infinite loop.
43
44=cut
45
46is($baz->foo,
47 'Foo::foo(Baz::foo and Foo::foo())',
1808c2da 48 'got the right value for 1 augmented subclass calling non-augmented subclass');
b468a3d3 49