bug for immutable class that does a role
Todd Hepler [Tue, 22 Jul 2008 01:44:42 +0000 (01:44 +0000)]
t/100_bugs/018_immutable_metaclass_does_role.t [new file with mode: 0644]

diff --git a/t/100_bugs/018_immutable_metaclass_does_role.t b/t/100_bugs/018_immutable_metaclass_does_role.t
new file mode 100644 (file)
index 0000000..874fc30
--- /dev/null
@@ -0,0 +1,47 @@
+
+{
+    package MyRole;
+    use Moose::Role;
+    BEGIN {
+        requires 'foo';
+    }
+    no Moose::Role;
+}
+{
+    package MyMetaclass;
+    use Moose;
+    BEGIN {
+        sub foo { 'i am foo' }
+        extends 'Moose::Meta::Class';
+        with 'MyRole';
+    }
+    no Moose;
+}
+
+{
+    package MyClass;
+    use metaclass 'MyMetaclass';
+    use Moose;
+    no Moose;
+}
+
+use Test::More tests => 5;
+
+my $a = MyClass->new;
+ok( $a->meta->meta->does_role('MyRole'), 'metaclass does MyRole' );
+
+# now try combinations of having the class/metaclass made immutable
+# and run the same test
+
+MyClass->meta->make_immutable;
+ok( $a->meta->meta->does_role('MyRole'), 'metaclass does MyRole' );
+
+MyClass->meta->make_mutable;
+ok( $a->meta->meta->does_role('MyRole'), 'metaclass does MyRole' );
+
+MyMetaclass->meta->make_immutable;
+ok( $a->meta->meta->does_role('MyRole'), 'metaclass does MyRole' );
+
+MyClass->meta->make_immutable;
+ok( $a->meta->meta->does_role('MyRole'), 'metaclass does MyRole' );
+