X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fnative_traits%2Ftrait_hash.t;h=a75a851006eb682239d3bb4aab328199e1b4cc1c;hb=ed4553423d437c734ffe1397a7fce887f0b40d9b;hp=36dd0becf884f7e97f49a6937e2e3b50595b2ce8;hpb=9af9be92f465838985e280383dea0f7ab63fb399;p=gitmo%2FMoose.git diff --git a/t/native_traits/trait_hash.t b/t/native_traits/trait_hash.t index 36dd0be..a75a851 100644 --- a/t/native_traits/trait_hash.t +++ b/t/native_traits/trait_hash.t @@ -98,6 +98,18 @@ sub run_tests { ); }, undef, '... set the option okay' ); + like( + exception { $obj->set_option( foo => 'bar', 'baz' ) }, + qr/You must pass an even number of arguments to set/, + 'exception with odd number of arguments' + ); + + like( + exception { $obj->set_option( undef, 'bar' ) }, + qr/Hash keys passed to set must be defined/, + 'exception when using undef as a key' + ); + ok( $obj->is_defined('foo'), '... foo is defined' ); ok( !$obj->has_no_options, '... we have options' ); @@ -186,6 +198,12 @@ sub run_tests { 'error when calling accessor with no arguments' ); + like( + exception { $obj->option_accessor( undef, 'bar' ) }, + qr/Hash keys passed to accessor must be defined/, + 'exception when using undef as a key' + ); + is_deeply( $obj->options, { quantity => 4, size => 42 }, 'accessor as writer'