Regenerate test files
[gitmo/Mouse.git] / t / 010_basics / 004_inner_and_augment.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
fde8e43f 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;
60ad2cb7 5
6use strict;
7use warnings;
8
fde8e43f 9use Test::More;
60ad2cb7 10use Test::Exception;
11
12
60ad2cb7 13{
14 package Foo;
15 use Mouse;
16
17 sub foo { 'Foo::foo(' . (inner() || '') . ')' }
18 sub bar { 'Foo::bar(' . (inner() || '') . ')' }
19 sub baz { 'Foo::baz(' . (inner() || '') . ')' }
20
21 package Bar;
22 use Mouse;
23
24 extends 'Foo';
25
26 augment foo => sub { 'Bar::foo(' . (inner() || '') . ')' };
27 augment bar => sub { 'Bar::bar' };
28
29 no Mouse; # ensure inner() still works after unimport
30
31 package Baz;
32 use Mouse;
33
34 extends 'Bar';
35
36 augment foo => sub { 'Baz::foo' };
37 augment baz => sub { 'Baz::baz' };
38
39 # this will actually never run,
40 # because Bar::bar does not call inner()
41 augment bar => sub { 'Baz::bar' };
42}
43
44my $baz = Baz->new();
45isa_ok($baz, 'Baz');
46isa_ok($baz, 'Bar');
47isa_ok($baz, 'Foo');
48
49is($baz->foo(), 'Foo::foo(Bar::foo(Baz::foo))', '... got the right value from &foo');
50is($baz->bar(), 'Foo::bar(Bar::bar)', '... got the right value from &bar');
51is($baz->baz(), 'Foo::baz(Baz::baz)', '... got the right value from &baz');
52
53my $bar = Bar->new();
54isa_ok($bar, 'Bar');
55isa_ok($bar, 'Foo');
56
57is($bar->foo(), 'Foo::foo(Bar::foo())', '... got the right value from &foo');
58is($bar->bar(), 'Foo::bar(Bar::bar)', '... got the right value from &bar');
59is($bar->baz(), 'Foo::baz()', '... got the right value from &baz');
60
61my $foo = Foo->new();
62isa_ok($foo, 'Foo');
63
64is($foo->foo(), 'Foo::foo()', '... got the right value from &foo');
65is($foo->bar(), 'Foo::bar()', '... got the right value from &bar');
66is($foo->baz(), 'Foo::baz()', '... got the right value from &baz');
67
68# some error cases
69
70{
71 package Bling;
72 use Mouse;
73
74 sub bling { 'Bling::bling' }
75
76 package Bling::Bling;
77 use Mouse;
78
79 extends 'Bling';
80
81 sub bling { 'Bling::bling' }
82
83 ::dies_ok {
84 augment 'bling' => sub {};
85 } '... cannot augment a method which has a local equivalent';
86
87}
88
fde8e43f 89done_testing;