Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Moose/t/attributes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Moose/t/attributes/delegation_arg_aliasing.t
use strict;
use warnings;
use Test::More;

{
    package Foo;
    use Moose;

    sub aliased {
        my $self = shift;
        $_[1] = $_[0];
    }
}

{
    package HasFoo;
    use Moose;

    has foo => (
        is  => 'ro',
        isa => 'Foo',
        handles => {
            foo_aliased => 'aliased',
            foo_aliased_curried => ['aliased', 'bar'],
        }
    );
}

my $hasfoo = HasFoo->new(foo => Foo->new);
my $x;
$hasfoo->foo->aliased('foo', $x);
is($x, 'foo', "direct aliasing works");
undef $x;
$hasfoo->foo_aliased('foo', $x);
is($x, 'foo', "delegated aliasing works");
undef $x;
$hasfoo->foo_aliased_curried($x);
is($x, 'bar', "delegated aliasing with currying works");

done_testing;

Hry