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