test for "does" on attrs
Arthur Axel 'fREW' Schmidt [Wed, 4 Apr 2012 23:45:04 +0000 (18:45 -0500)]
xt/moose-does-moo-role.t [new file with mode: 0644]

diff --git a/xt/moose-does-moo-role.t b/xt/moose-does-moo-role.t
new file mode 100644 (file)
index 0000000..2e84eb6
--- /dev/null
@@ -0,0 +1,48 @@
+use strictures 1;
+use Test::More;
+use Test::Exception;
+
+use Moo::HandleMoose;
+
+{
+   package MooRole;
+   use Moo::Role;
+
+   package MooRoledMooClass;
+   use Moo;
+   with 'MooRole';
+
+   package MooRoledMooseClass;
+   use Moose;
+   with 'MooRole';
+
+   package MooseParent;
+   use Moose;
+
+   has e => (
+      is       => 'ro',
+      required => 1,
+      does     => 'MooRole',
+   );
+
+   package MooParent;
+   use Moo;
+
+   has e => (
+      is       => 'ro',
+      required => 1,
+      does     => 'MooRole',
+   );
+}
+
+for my $parent (qw(MooseParent MooParent)) {
+   for my $child (qw(MooRoledMooClass MooRoledMooseClass)) {
+      lives_ok {
+         $parent->new(
+            e => $child->new(),
+         );
+      } "$parent instantiated with a $child delegate that does a MooRole";
+   }
+}
+
+done_testing;