1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
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;
|