From: Dave Rolsky Date: Fri, 29 Oct 2010 21:30:03 +0000 (-0500) Subject: Fix error when no arguments are passed to Hash's accessor method X-Git-Tag: 1.18~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4343331780160a4e042f64c982e6839e4c05bee1;p=gitmo%2FMoose.git Fix error when no arguments are passed to Hash's accessor method --- diff --git a/lib/Moose/Meta/Method/Accessor/Native/Hash/accessor.pm b/lib/Moose/Meta/Method/Accessor/Native/Hash/accessor.pm index f519b2b..9713a85 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Hash/accessor.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Hash/accessor.pm @@ -75,7 +75,7 @@ sub _generate_method { } # If we get one argument we won't check the argument count -sub _minimum_arguments {2} +sub _minimum_arguments {1} sub _maximum_arguments {2} no Moose::Role; diff --git a/t/070_native_traits/050_trait_hash.t b/t/070_native_traits/050_trait_hash.t index 4ff4671..77bd39a 100644 --- a/t/070_native_traits/050_trait_hash.t +++ b/t/070_native_traits/050_trait_hash.t @@ -178,6 +178,10 @@ sub run_tests { $obj->option_accessor( size => 42 ); + like( exception { + $obj->option_accessor; + }, qr/Cannot call accessor without at least 1 argument/, '... options added okay with defaults' ); + is_deeply( $obj->options, { quantity => 4, size => 42 }, 'accessor as writer' @@ -270,7 +274,6 @@ sub run_tests { 'kv returns lazy default' ); - $obj->_clear_options; $obj->option_accessor( y => 2 );