Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 009_augment_recursion_bug.t
CommitLineData
4c98ebb0 1#!/usr/bin/perl
ee5e6a03 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
4c98ebb0 5
6use strict;
7use warnings;
8
ee5e6a03 9use Test::More;
4c98ebb0 10
11
12{
13 package Foo;
14 use Mouse;
15
16 sub foo { 'Foo::foo(' . (inner() || '') . ')' };
17
18 package Bar;
19 use Mouse;
20
21 extends 'Foo';
22
23 package Baz;
24 use Mouse;
25
26 extends 'Foo';
27
28 my $foo_call_counter;
29 augment 'foo' => sub {
30 die "infinite loop on Baz::foo" if $foo_call_counter++ > 1;
31 return 'Baz::foo and ' . Bar->new->foo;
32 };
33}
34
35my $baz = Baz->new();
36isa_ok($baz, 'Baz');
37isa_ok($baz, 'Foo');
38
39=pod
40
41When a subclass which augments foo(), calls a subclass which does not augment
42foo(), there is a chance for some confusion. If Mouse does not realize that
43Bar does not augment foo(), because it is in the call flow of Baz which does,
44then we may have an infinite loop.
45
46=cut
47
48is($baz->foo,
49 'Foo::foo(Baz::foo and Foo::foo())',
50 '... got the right value for 1 augmented subclass calling non-augmented subclass');
51
ee5e6a03 52done_testing;