From: Todd Hepler Date: Tue, 22 Jul 2008 01:44:42 +0000 (+0000) Subject: bug for immutable class that does a role X-Git-Tag: 0_55~44 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e93d7b01649aa32c68a760cdfc18306569dd332;p=gitmo%2FMoose.git bug for immutable class that does a role --- 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 index 0000000..874fc30 --- /dev/null +++ b/t/100_bugs/018_immutable_metaclass_does_role.t @@ -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' ); +