update broken dependents
[gitmo/Moo.git] / t / accessor-generator-extension.t
index 3164bf6..d894639 100644 (file)
@@ -42,19 +42,21 @@ BEGIN {
   }
 
   sub default_construction_string { '[]' }
+
+  sub MooX::ArrayRef::import { 
+    Moo::Role->apply_roles_to_object(
+      Moo->_accessor_maker_for(scalar caller),
+      'Method::Generate::Accessor::Role::ArrayRefInstance'
+    );
+  }
+  $INC{"MooX/ArrayRef.pm"} = 1;
 }
 
 {
   package ArrayTest1;
 
   use Moo;
-
-  BEGIN {
-     Moo::Role->apply_roles_to_object(
-       Moo->_accessor_maker_for(__PACKAGE__),
-      'Method::Generate::Accessor::Role::ArrayRefInstance'
-     )
-  }
+  use MooX::ArrayRef;
 
   has one => (is => 'ro');
   has two => (is => 'ro');
@@ -79,4 +81,24 @@ $o = ArrayTest2->new(one => 1, two => 2, three => 3, four => 4);
 
 is_deeply([ @$o ], [ 1, 2, 3, 4 ], 'Subclass object ok');
 
+{
+  package ArrayTestRole;
+
+  use Moo::Role;
+
+  has four => (is => 'ro');
+
+  package ArrayTest3;
+
+  use Moo;
+
+  extends 'ArrayTest1';
+
+  with 'ArrayTestRole';
+}
+
+$o = ArrayTest3->new(one => 1, two => 2, three => 3, four => 4);
+
+is_deeply([ @$o ], [ 1, 2, 3, 4 ], 'Subclass object w/role');
+
 done_testing;