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 :  /proc/self/root/usr/share/doc/perl-Moose/t/cmop/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/share/doc/perl-Moose/t/cmop/RT_27329_fix.t
use strict;
use warnings;

use Test::More;

use Class::MOP;

=pod

This tests a bug sent via RT #27329

=cut

{
    package Foo;
    use metaclass;

    Foo->meta->add_attribute('foo' => (
        init_arg => 'foo',
        reader   => 'get_foo',
        default  => 'BAR',
    ));

}

my $foo = Foo->meta->new_object;
isa_ok($foo, 'Foo');

is($foo->get_foo, 'BAR', '... got the right default value');

{
    my $clone = $foo->meta->clone_object($foo, foo => 'BAZ');
    isa_ok($clone, 'Foo');
    isnt($clone, $foo, '... and it is a clone');

    is($clone->get_foo, 'BAZ', '... got the right cloned value');
}

{
    my $clone = $foo->meta->clone_object($foo, foo => undef);
    isa_ok($clone, 'Foo');
    isnt($clone, $foo, '... and it is a clone');

    ok(!defined($clone->get_foo), '... got the right cloned value');
}

done_testing;

Hry