Fail with namespace::autoclean
Tomas Doran [Sun, 15 Jul 2012 11:19:42 +0000 (12:19 +0100)]
xt/lib/withautoclean/Class.pm [new file with mode: 0644]
xt/lib/withautoclean/R1.pm [new file with mode: 0644]
xt/withautoclean.t [new file with mode: 0644]

diff --git a/xt/lib/withautoclean/Class.pm b/xt/lib/withautoclean/Class.pm
new file mode 100644 (file)
index 0000000..ad0f397
--- /dev/null
@@ -0,0 +1,10 @@
+package withautoclean::Class;
+use Moo;
+
+with 'withautoclean::R1';
+
+before _clear_ctx => sub {
+};
+
+1;
+
diff --git a/xt/lib/withautoclean/R1.pm b/xt/lib/withautoclean/R1.pm
new file mode 100644 (file)
index 0000000..f2fc608
--- /dev/null
@@ -0,0 +1,18 @@
+package withautoclean::R1;
+use Moo::Role;
+
+# Doing this (or loading a class which is built with Moose)
+# and then loading autoclean - everything breaks...
+use Moose ();
+use namespace::autoclean;
+# Wouldn't happen normally, but is likely to as you part-port something.
+
+has _ctx => (
+    is => 'ro',
+    default => sub {
+    },
+    clearer => '_clear_ctx',
+);
+
+1;
+
diff --git a/xt/withautoclean.t b/xt/withautoclean.t
new file mode 100644 (file)
index 0000000..6d9e807
--- /dev/null
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+use FindBin qw/ $Bin /;
+use lib "$Bin/lib";
+use Test::More;
+
+use_ok 'withautoclean::Class';
+
+done_testing;
+