4 use Test::More tests => 10;
33 my ($self, @args) = @_;
34 $self->meta->clone_object($self, @args);
38 my $foo = Foo->new(bar => [ 1, 2, 3 ], quuux => "indeed");
40 is($foo->foo, "foo", "attr 1",);
41 is($foo->quux, "indeed", "init_arg respected");
42 is_deeply($foo->bar, [ 1 .. 3 ], "attr 2");
45 my $clone = $foo->clone(foo => "dancing", baz => "bar", quux => "nope", quuux => "yes");
47 is($clone->foo, "dancing", "overridden attr");
48 is_deeply($clone->bar, [ 1 .. 3 ], "clone attr");
49 is($clone->baz, "foo", "init_arg=undef means the attr is ignored");
50 is($clone->quux, "yes", "clone uses init_arg and not attribute name");
53 Foo->meta->clone_object("constant");
54 } qr/You must pass an instance of the metaclass \(Foo\), not \(constant\)/;
57 Foo->meta->clone_object(Foo->meta)
58 } qr/You must pass an instance of the metaclass \(Foo\), not \(Mo.se::Meta::Class=HASH\(\w+\)\)/;
61 Foo->meta->clone_instance("constant")
62 } qr/You can only clone instances, \(constant\) is not a blessed instance/;