Moo using Moose Roles incompatibility
Tomas Doran [Sun, 15 Jul 2012 18:02:23 +0000 (19:02 +0100)]
xt/moo-consume-moose-role-coerce.t [new file with mode: 0644]

diff --git a/xt/moo-consume-moose-role-coerce.t b/xt/moo-consume-moose-role-coerce.t
new file mode 100644 (file)
index 0000000..a21a88c
--- /dev/null
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+use Test::More;
+
+{
+    package RoleOne;
+    use Moose::Role;
+    use Moose::Util::TypeConstraints;
+    use namespace::autoclean;
+
+    subtype 'Foo', as 'Int';
+    coerce 'Foo', from 'Str', via { 3 };
+
+    has foo => (
+        is => 'rw',
+        isa => 'Foo',
+        coerce => 1,
+        clearer => '_clear_foo',
+    );
+}
+{
+    package Class;
+    use Moo; # Works if use Moose..
+    use namespace::clean -except => 'meta';
+
+    with 'RoleOne';
+}
+
+my $i = Class->new( foo => 'bar' );
+is $i->foo, 3;
+
+done_testing;
+