Add a failing test for the following construct, which explodes due to metaclass incom...
Shawn M Moore [Thu, 11 Sep 2008 06:39:57 +0000 (06:39 +0000)]
package Parent;
use Moose -traits => ...;
package Child;
use base 'Parent';

t/050_metaclasses/017_traits_plain_subclass.t [new file with mode: 0644]

diff --git a/t/050_metaclasses/017_traits_plain_subclass.t b/t/050_metaclasses/017_traits_plain_subclass.t
new file mode 100644 (file)
index 0000000..8687e7d
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+use Test::Exception;
+
+{
+    package NoOpTrait;
+    use Moose::Role;
+}
+
+{
+    package Parent;
+    use Moose -traits => 'NoOpTrait';
+
+    has attr => (
+        is  => 'rw',
+        isa => 'Str',
+    );
+}
+
+{
+    package Child;
+    use base 'Parent';
+}
+
+is(Child->meta->name, 'Child', "correct metaclass name");
+
+my $child = Child->new(attr => "ibute");
+ok($child, "constructor works");
+
+is($child->attr, "ibute", "getter inherited properly");
+
+$child->attr("ition");
+is($child->attr, "ition", "setter inherited properly");
+