Add another MOOSE_TEST_MD option, MooseX
[gitmo/Moose.git] / t / native_traits / trait_hash.t
index d319ee8..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'
@@ -293,14 +311,21 @@ sub run_tests {
 }
 
 {
-    my ($class, $handles) = build_class(isa => 'HashRef');
+    my ( $class, $handles ) = build_class( isa => 'HashRef' );
     my $obj = $class->new;
     with_immutable {
-        is(exception { $obj->option_accessor('foo', undef) }, undef,
-           "can use accessor to set to undef");
-        is(exception { $obj->quantity(undef) }, undef,
-           "can use accessor to set to undef");
-    } $class;
+        is(
+            exception { $obj->option_accessor( 'foo', undef ) },
+            undef,
+            'can use accessor to set value to undef'
+        );
+        is(
+            exception { $obj->quantity(undef) },
+            undef,
+            'can use accessor to set value to undef'
+        );
+    }
+    $class;
 }
 
 done_testing;