Reorganize t/020_attributes/
[gitmo/Mouse.git] / t / 020_attributes / 032_delegation_arg_aliasing.t
CommitLineData
1f5ce14a 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!!!
4use t::lib::MooseCompat;
5use strict;
6use warnings;
7use 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
33my $hasfoo = HasFoo->new(foo => Foo->new);
34my $x;
35$hasfoo->foo->aliased('foo', $x);
36is($x, 'foo', "direct aliasing works");
37undef $x;
38$hasfoo->foo_aliased('foo', $x);
39is($x, 'foo', "delegated aliasing works");
40undef $x;
41$hasfoo->foo_aliased_curried($x);
42is($x, 'bar', "delegated aliasing with currying works");
43
44done_testing;