adding documentation slot to the attributes
[gitmo/Moose.git] / t / 071_misc_attribute_tests.t
index eb22962..3849d64 100644 (file)
@@ -3,35 +3,67 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 6;
 use Test::Exception;
 
 BEGIN {
     use_ok('Moose');           
 }
 
-## Roles
-
 {
-    package Test::TheDefaultFor::ArrayRef::and::HashRef;
-    use Moose;
-    
-    has 'array_ref' => (is => 'rw', isa => 'ArrayRef');
-    has 'hash_ref'  => (is => 'rw', isa => 'HashRef');    
+    {
+        package Test::Attribute::Inline::Documentation;
+        use Moose;
 
+        has 'foo' => (
+            documentation => q{
+                The 'foo' attribute is my favorite 
+                attribute in the whole wide world.
+            }
+        );
+    }
+    
+    my $foo_attr = Test::Attribute::Inline::Documentation->meta->get_attribute('foo');
+    
+    ok($foo_attr->has_documentation, '... the foo has docs');
+    is($foo_attr->documentation,
+            q{
+                The 'foo' attribute is my favorite 
+                attribute in the whole wide world.
+            },
+    '... got the foo docs');
 }
 
-my $test = Test::TheDefaultFor::ArrayRef::and::HashRef->new;
-isa_ok($test, 'Test::TheDefaultFor::ArrayRef::and::HashRef');
+{
+    {
+        package Test::For::Lazy::TypeConstraint;
+        use Moose;
+        use Moose::Util::TypeConstraints;
 
-is_deeply($test->array_ref, [], '.... got the right default value');
-is_deeply($test->hash_ref,  {}, '.... got the right default value');
+        has 'bad_lazy_attr' => (
+            is => 'rw',
+            isa => 'ArrayRef',
+            lazy => 1, 
+            default => sub { "test" },
+        );
+        
+        has 'good_lazy_attr' => (
+            is => 'rw',
+            isa => 'ArrayRef',
+            lazy => 1, 
+            default => sub { [] },
+        );        
 
-my $test2 = Test::TheDefaultFor::ArrayRef::and::HashRef->new(
-    array_ref => [ 1, 2, [] ],
-    hash_ref  => { one => 1, two => 2, three => {} },
-);
-isa_ok($test2, 'Test::TheDefaultFor::ArrayRef::and::HashRef');
+    }
 
-is_deeply($test2->array_ref, [ 1, 2, [] ], '.... got the right default value');
-is_deeply($test2->hash_ref,  { one => 1, two => 2, three => {} }, '.... got the right default value');
\ No newline at end of file
+    my $test = Test::For::Lazy::TypeConstraint->new;
+    isa_ok($test, 'Test::For::Lazy::TypeConstraint');
+    
+    dies_ok {
+        $test->bad_lazy_attr;
+    } '... this does not work';
+    
+    lives_ok {
+        $test->good_lazy_attr;
+    } '... this does not work';    
+}