make sure the correct delegation name is used in errors
[gitmo/Moose.git] / t / native_traits / trait_hash.t
index 36dd0be..a75a851 100644 (file)
@@ -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'