Test that accessor works with lazy generation
Dave Rolsky [Fri, 29 Oct 2010 14:12:19 +0000 (09:12 -0500)]
t/070_native_traits/050_trait_hash.t

index f39040b..b64137b 100644 (file)
@@ -24,6 +24,7 @@ use Test::Moose;
         has_option       => 'exists',
         get_option       => 'get',
         has_no_options   => 'is_empty',
+        keys             => 'keys',
         key_value        => 'kv',
         set_option       => 'set',
     );
@@ -243,6 +244,17 @@ sub run_tests {
                 [ [ x => 1 ] ],
                 'kv returns lazy default'
             );
+
+
+            $obj->_clear_options;
+
+            $obj->option_accessor( y => 2 );
+
+            is_deeply(
+                [ sort $obj->keys ],
+                [ 'x', 'y' ],
+                'accessor triggers lazy default generator'
+            );
         }
     }
     $class;