correct filename of Moo::Object in test
[gitmo/Moo.git] / xt / moo-roles-into-moose-class.t
index d1d0a6c..c22f406 100644 (file)
@@ -1,11 +1,13 @@
 use strict;
 use warnings;
 use Test::More;
+use Test::Fatal;
 
 {
     package Foo;
     use Moo::Role;
-    use namespace::autoclean;
+    # if we autoclean here there's nothing left and then load_class tries
+    # to require Foo during Moose application and everything breaks.
 }
 {
     package Bar;
@@ -29,6 +31,8 @@ use Test::More;
 
 ::is(Baz->can('thing'), Bar->can('thing'), 'Role copies method correctly');
 ::ok(Baz->can('attr'), 'Attr accessor correct');
+::ok(!Bar->can('has'), 'Moo::Role sugar removed by autoclean');
+::ok(!Bar->can('with'), 'Role::Tiny sugar removed by autoclean');
 ::ok(!Baz->can('has'), 'Sugar not copied');
 
 {
@@ -40,6 +44,27 @@ use Test::More;
     /;
 }
 
-ok 1;
+{
+    package Baw;
+    use Moo::Role;
+    has attr => (
+        is => 'ro',
+        traits => ['Array'],
+        default => sub { [] },
+        handles => {
+            push_attr => 'push',
+        },
+    );
+}
+{
+    package Buh;
+    use Moose;
+    with 'Baw';
+}
+
+is exception {
+  Buh->new->push_attr(1);
+}, undef, 'traits in role attributes are inflated properly';
+
 done_testing;