4 use Test::More tests => 11;
14 is_deeply( C->BUILDARGS(), {} );
15 is_deeply( C->BUILDARGS(foo => 42), {foo => 42} );
16 is_deeply( C->BUILDARGS(foo => 42, foo => 'bar'), {foo => 'bar'} );
17 is_deeply( C->BUILDARGS({foo => 1, bar => 2}), {foo => 1, bar => 2} );
19 my %hash = (foo => 10);
20 my $args = C->BUILDARGS(\%hash);
22 is $hash{foo}, 10, 'values must be copied';
25 $args = C->BUILDARGS(%hash);
27 is $hash{foo}, 10, 'values must be copied';
31 } qr/must be a HASH ref/;
36 } qr/must be a HASH ref/;
45 has foo => ( is => "rw" );
48 my ( $self, @args ) = @_;
49 return { @args % 2 ? ( foo => @args ) : @args };
53 is(Foo->new->foo, undef, "no value");
54 is(Foo->new("bar")->foo, "bar", "single arg");
55 is(Foo->new(foo => "bar")->foo, "bar", "twoargs");