remove trailing whitespace
[gitmo/Moose.git] / t / 020_attributes / 011_more_attr_delegation.t
index 10d5e8c..99a3b40 100644 (file)
@@ -3,9 +3,17 @@
 use strict;
 use warnings;
 
-use Test::More tests => 35;
+use Test::More tests => 39;
 use Test::Exception;
 
+=pod
+
+This tests the more complex
+delegation cases and that they
+do not fail at compile time.
+
+=cut
+
 {
 
     package ChildASuper;
@@ -63,6 +71,11 @@ use Test::Exception;
     sub child_f_method_1 { "f1" }
     sub child_f_method_2 { "f2" }
 
+    package ChildG;
+    use Moose;
+
+    sub child_g_method_1 { "g1" }
+
     package Parent;
     use Moose;
 
@@ -146,6 +159,14 @@ use Test::Exception;
 
     ::is( $delegate_class, "ChildF", "plain classes are handed down to subs" );
 
+    ::lives_ok {
+        has child_g => (
+            isa     => "ChildG",
+            default => sub { ChildG->new },
+            handles => ["child_g_method_1"],
+        );
+    } "can delegate to object even without explicit reader";
+
     sub parent_method { "p" }
 }
 
@@ -159,6 +180,8 @@ isa_ok( $p->child_d, "ChildD" );
 isa_ok( $p->child_e, "ChildE" );
 isa_ok( $p->child_f, "ChildF" );
 
+ok(!$p->can('child_g'), '... no child_g accessor defined');
+
 
 is( $p->parent_method, "p", "parent method" );
 is( $p->child_a->child_a_super_method, "as", "child supermethod" );
@@ -178,7 +201,7 @@ ok( !$p->can("child_b_method_2"), "but not ChildB's unspecified siblings" );
 
 
 ok( !$p->can($_), "none of ChildD's methods ($_)" )
-    for grep { /^child/ } map { $_->{name} } ChildD->meta->compute_all_applicable_methods();
+    for grep { /^child/ } map { $_->name } ChildD->meta->get_all_methods();
 
 can_ok( $p, "child_c_method_3_la" );
 can_ok( $p, "child_c_method_4_la" );
@@ -189,3 +212,6 @@ can_ok( $p, "child_e_method_2" );
 ok( !$p->can("child_e_method_1"), "but not child_e_method_1");
 
 is( $p->child_e_method_2, "e2", "delegate to non moose class (child_e_method_2)" );
+
+can_ok( $p, "child_g_method_1" );
+is( $p->child_g_method_1, "g1", "delegate to moose class without reader (child_g_method_1)" );