test for Moose consuming a role with no subs after Moo does
Graham Knop [Tue, 18 Dec 2012 13:49:54 +0000 (08:49 -0500)]
xt/lib/ExampleMooRole.pm [new file with mode: 0644]
xt/moose-consume-moo-role-after-consumed-by-moo.t [new file with mode: 0644]

diff --git a/xt/lib/ExampleMooRole.pm b/xt/lib/ExampleMooRole.pm
new file mode 100644 (file)
index 0000000..3dabe58
--- /dev/null
@@ -0,0 +1,8 @@
+package ExampleMooRole;
+use Moo::Role;
+
+$::ExampleMooRole_LOADED++;
+
+no Moo::Role;
+
+1;
diff --git a/xt/moose-consume-moo-role-after-consumed-by-moo.t b/xt/moose-consume-moo-role-after-consumed-by-moo.t
new file mode 100644 (file)
index 0000000..120f96f
--- /dev/null
@@ -0,0 +1,21 @@
+use strictures;
+use Test::More;
+use lib 'xt/lib';
+
+BEGIN { $::ExampleMooRole_LOADED = 0 }
+BEGIN {
+    package ExampleMooConsumer;
+    use Moo;
+
+    with "ExampleMooRole";
+}
+BEGIN {
+    package ExampleMooseConsumer;
+    use Moose;
+
+    with "ExampleMooRole";
+}
+
+is $::ExampleMooRole_LOADED, 1, "role loaded only once";
+
+done_testing;