X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_mouse%2F032-buildargs.t;h=49faaa833023e7517cd17538a81610b449adc0d8;hb=95637edb1de318b764f8ec2fc8b5c5c8d4430010;hp=4b286f3ef1b6cca8d976172a2bcb4d7d5654435e;hpb=920139b3efca66d2caeeef306c97fa0da62c6b73;p=gitmo%2FMouse.git 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;