Changelogging
[gitmo/Mouse.git] / t / 020_attributes / 032_delegation_arg_aliasing.t
1 #!/usr/bin/env 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 use strict;
6 use warnings;
7 use Test::More;
8
9 {
10     package Foo;
11     use Mouse;
12
13     sub aliased {
14         my $self = shift;
15         $_[1] = $_[0];
16     }
17 }
18
19 {
20     package HasFoo;
21     use Mouse;
22
23     has foo => (
24         is  => 'ro',
25         isa => 'Foo',
26         handles => {
27             foo_aliased => 'aliased',
28             foo_aliased_curried => ['aliased', 'bar'],
29         }
30     );
31 }
32
33 my $hasfoo = HasFoo->new(foo => Foo->new);
34 my $x;
35 $hasfoo->foo->aliased('foo', $x);
36 is($x, 'foo', "direct aliasing works");
37 undef $x;
38 $hasfoo->foo_aliased('foo', $x);
39 is($x, 'foo', "delegated aliasing works");
40 undef $x;
41 $hasfoo->foo_aliased_curried($x);
42 is($x, 'bar', "delegated aliasing with currying works");
43
44 done_testing;