Support modifier by regexp
[gitmo/Mouse.git] / t / 100_bugs / 009_augment_recursion_bug.t
CommitLineData
4c98ebb0 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 3;
7
8
9
10{
11 package Foo;
12 use Mouse;
13
14 sub foo { 'Foo::foo(' . (inner() || '') . ')' };
15
16 package Bar;
17 use Mouse;
18
19 extends 'Foo';
20
21 package Baz;
22 use Mouse;
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 Mouse does not realize that
41Bar does not augment foo(), because it is in the call flow of Baz which does,
42then we may have an infinite loop.
43
44=cut
45
46is($baz->foo,
47 'Foo::foo(Baz::foo and Foo::foo())',
48 '... got the right value for 1 augmented subclass calling non-augmented subclass');
49