0fca0a7a61c56b2aec0c97bfcb2504e1a7d6dc3e
[gitmo/Mouse.git] / t / 020_attributes / 031_delegation_and_modifiers.t
1 #!/usr/bin/perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
10 use Test::Exception;
11
12 {
13     package Bar;
14     use Mouse;
15
16     sub baz   { 'Bar::baz' }
17     sub gorch { 'Bar::gorch' }
18
19     package Foo;
20     use Mouse;
21
22     has 'bar' => (
23         is      => 'ro',
24         isa     => 'Bar',
25         lazy    => 1,
26         default => sub { Bar->new },
27         handles => [qw[ baz gorch ]]
28     );
29
30     package Foo::Extended;
31     use Mouse;
32
33     extends 'Foo';
34
35     has 'test' => (
36         is      => 'rw',
37         isa     => 'Bool',
38         default => sub { 0 },
39     );
40
41     around 'bar' => sub {
42         my $next = shift;
43         my $self = shift;
44
45         $self->test(1);
46         $self->$next();
47     };
48 }
49
50 my $foo = Foo::Extended->new;
51 isa_ok($foo, 'Foo::Extended');
52 isa_ok($foo, 'Foo');
53
54 ok(!$foo->test, '... the test value has not been changed');
55
56 is($foo->baz, 'Bar::baz', '... got the right delegated method');
57
58 ok($foo->test, '... the test value has now been changed');
59
60 done_testing;