make non-lazy builder work
[gitmo/MooseX-ClassAttribute.git] / t / lib / SharedTests.pm
index 970bc94..1299263 100644 (file)
@@ -76,6 +76,17 @@ use Test::More;
           },
         );
 
+    class_has 'Built' =>
+        ( is      => 'ro',
+          builder => '_BuildIt',
+        );
+
+    class_has 'LazyBuilt' =>
+        ( is      => 'ro',
+          lazy    => 1,
+          builder => '_BuildIt',
+        );
+
     has 'size' =>
         ( is      => 'rw',
           isa     => 'Int',
@@ -91,6 +102,8 @@ use Test::More;
         $self->ObjectCount( $self->ObjectCount() + 1 );
     }
 
+    sub _BuildIt { 42 }
+
     sub make_immutable
     {
         my $class = shift;
@@ -139,7 +152,7 @@ use Test::More;
 
 sub run_tests
 {
-    plan tests => 24;
+    plan tests => 26;
 
     local $Test::Builder::Level = $Test::Builder::Level + 1;
 
@@ -243,6 +256,14 @@ sub run_tests
         is( HasClassAttribute->GetMapping('a'), 20,
             'value for a in mapping is 20' );
     }
+
+    {
+        is( HasClassAttribute->Built(), 42,
+            'attribute with builder works' );
+
+        is( HasClassAttribute->LazyBuilt(), 42,
+            'attribute with lazy builder works' );
+    }
 }