We only need local $? if we inline calls to DEMOLISH
[gitmo/Moose.git] / t / attributes / delegation_arg_aliasing.t
CommitLineData
c279b82f 1#!/usr/bin/env perl
2use strict;
3use warnings;
a28e50e4 4use Test::More;
c279b82f 5
6{
7 package Foo;
8 use Moose;
9
10 sub aliased {
11 my $self = shift;
12 $_[1] = $_[0];
13 }
14}
15
16{
17 package HasFoo;
18 use Moose;
19
20 has foo => (
21 is => 'ro',
22 isa => 'Foo',
23 handles => {
24 foo_aliased => 'aliased',
25 foo_aliased_curried => ['aliased', 'bar'],
26 }
27 );
28}
29
30my $hasfoo = HasFoo->new(foo => Foo->new);
31my $x;
32$hasfoo->foo->aliased('foo', $x);
33is($x, 'foo', "direct aliasing works");
34undef $x;
35$hasfoo->foo_aliased('foo', $x);
36is($x, 'foo', "delegated aliasing works");
37undef $x;
38$hasfoo->foo_aliased_curried($x);
39is($x, 'bar', "delegated aliasing with currying works");
a28e50e4 40
41done_testing;