Add canonicalize_args, factor lazy_build canonicalization/validation into the right...
[gitmo/Mouse.git] / t / 031-clone.t
CommitLineData
7a59f4e8 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More 'no_plan';
7
8{
9 package Foo;
10 use Mouse;
11
12 has foo => (
13 isa => "Str",
14 is => "rw",
15 default => "foo",
16 );
17
18 has bar => (
19 isa => "ArrayRef",
20 is => "rw",
21 );
22
23 sub clone {
24 my ( $self, @args ) = @_;
25 $self->meta->clone_object( $self, @args );
26 }
27}
28
29my $foo = Foo->new( bar => [ 1, 2, 3 ] );
30
31is( $foo->foo, "foo", "attr 1", );
32is_deeply( $foo->bar, [ 1 .. 3 ], "attr 2" );
33
34my $clone = $foo->clone( foo => "dancing" );
35
36is( $clone->foo, "dancing", "overridden attr" );
37is_deeply( $clone->bar, [ 1 .. 3 ], "clone attr" );
38