DEATH TO ALL zionist ELLIPSES
[gitmo/Moose.git] / t / 020_attributes / 001_attribute_reader_generation.t
index d6a4183..3e6db15 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 14;
+use Test::More tests => 20;
 use Test::Exception;
 
 
@@ -17,7 +17,7 @@ use Test::Exception;
             reader => 'get_foo'
         );
     };
-    ::ok(!$@, '... created the reader method okay');
+    ::ok(!$@, 'created the reader method okay');
 
     eval {
         has 'lazy_foo' => (
@@ -26,7 +26,7 @@ use Test::Exception;
             default => sub { 10 }
         );
     };
-    ::ok(!$@, '... created the lazy reader method okay') or warn $@;
+    ::ok(!$@, 'created the lazy reader method okay') or warn $@;
 
     my $warn;
 
@@ -36,7 +36,7 @@ use Test::Exception;
             reder => 'get_mftnpy'
         );
     };
-    ::ok($warn, '... got a warning for mispelled attribute argument');
+    ::ok($warn, 'got a warning for mispelled attribute argument');
 }
 
 {
@@ -44,26 +44,43 @@ use Test::Exception;
     isa_ok($foo, 'Foo');
 
     can_ok($foo, 'get_foo');
-    is($foo->get_foo(), undef, '... got an undefined value');
+    is($foo->get_foo(), undef, 'got an undefined value');
     dies_ok {
         $foo->get_foo(100);
-    } '... get_foo is a read-only';
+    } 'get_foo is a read-only';
 
-    ok(!exists($foo->{lazy_foo}), '... no value in get_lazy_foo slot');
+    ok(!exists($foo->{lazy_foo}), 'no value in get_lazy_foo slot');
 
     can_ok($foo, 'get_lazy_foo');
-    is($foo->get_lazy_foo(), 10, '... got an deferred value');
+    is($foo->get_lazy_foo(), 10, 'got an deferred value');
     dies_ok {
         $foo->get_lazy_foo(100);
-    } '... get_lazy_foo is a read-only';
+    } 'get_lazy_foo is a read-only';
+}
+
+{
+    my $foo = Foo->new;
+    isa_ok($foo, 'Foo');
+
+    my $attr = $foo->meta->find_attribute_by_name("lazy_foo");
+
+    isa_ok( $attr, "Moose::Meta::Attribute" );
+
+    ok( $attr->is_lazy, "it's lazy" );
+
+    is( $attr->get_raw_value($foo), undef, "raw value" );
+
+    is( $attr->get_value($foo), 10, "lazy value" );
+
+    is( $attr->get_raw_value($foo), 10, "raw value" );
 }
 
 {
     my $foo = Foo->new(foo => 10, lazy_foo => 100);
     isa_ok($foo, 'Foo');
 
-    is($foo->get_foo(), 10, '... got the correct value');
-    is($foo->get_lazy_foo(), 100, '... got the correct value');
+    is($foo->get_foo(), 10, 'got the correct value');
+    is($foo->get_lazy_foo(), 100, 'got the correct value');
 }