X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=t%2F001_mouse%2F032-buildargs.t;h=49faaa833023e7517cd17538a81610b449adc0d8;hp=4b286f3ef1b6cca8d976172a2bcb4d7d5654435e;hb=5ecfc2defd2955d68c9cbc3ad048ce80bd1020da;hpb=64f61124b57755ab2a2bc41f9e839efe0d8b80e0 diff --git a/t/001_mouse/032-buildargs.t b/t/001_mouse/032-buildargs.t index 4b286f3..49faaa8 100644 --- a/t/001_mouse/032-buildargs.t +++ b/t/001_mouse/032-buildargs.t @@ -1,7 +1,42 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 11; +use Test::Exception; + +{ + package C; + use Mouse; +} + +# original BUILDARGS + +is_deeply( C->BUILDARGS(), {} ); +is_deeply( C->BUILDARGS(foo => 42), {foo => 42} ); +is_deeply( C->BUILDARGS(foo => 42, foo => 'bar'), {foo => 'bar'} ); +is_deeply( C->BUILDARGS({foo => 1, bar => 2}), {foo => 1, bar => 2} ); + +my %hash = (foo => 10); +my $args = C->BUILDARGS(\%hash); +$args->{foo}++; +is $hash{foo}, 10, 'values must be copied'; + +%hash = (foo => 10); +$args = C->BUILDARGS(%hash); +$args->{foo}++; +is $hash{foo}, 10, 'values must be copied'; + +throws_ok { + C->BUILDARGS([]); +} qr/must be a HASH ref/; + + +throws_ok { + C->BUILDARGS([]); +} qr/must be a HASH ref/; + + +# custom BUILDARGS do { package Foo;