failing test for composite roles and application metaclasses topic/composite_bug
Moritz Onken [Thu, 20 Jan 2011 13:32:59 +0000 (14:32 +0100)]
t/030_roles/027_role_composition_meta.t [new file with mode: 0644]

diff --git a/t/030_roles/027_role_composition_meta.t b/t/030_roles/027_role_composition_meta.t
new file mode 100644 (file)
index 0000000..3891bce
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More;
+use Moose::Exporter;
+
+my $attributes_applied = 0;
+
+{
+    
+    package MyMoose;
+    use Moose;
+    
+    Moose::Exporter->setup_import_methods(
+                  role_metaroles => {
+                      application_to_class =>
+                        ['Application'],
+                  }, );
+
+    package Application;
+    use Moose::Role;
+
+    before apply_attributes => sub {
+        $attributes_applied++;
+    };
+
+    package RoleA;
+    use Moose::Role;
+    MyMoose->import;
+
+
+
+    has bar => ( is => 'rw', default => 1 );
+
+    package RoleB;
+    use Moose::Role;
+    MyMoose->import;
+
+    has foo => ( is => 'rw', default => 1 );
+}
+
+{
+
+    package ComposeList;
+
+    use Moose;
+    use namespace::autoclean;
+
+    with qw( RoleB RoleA );
+
+    __PACKAGE__->meta->make_immutable;
+}
+
+is($attributes_applied, 2);
+
+{
+
+    package ComposeSeparate;
+
+    use Moose;
+    use namespace::autoclean;
+
+    with 'RoleA';
+    with 'RoleB';
+
+    __PACKAGE__->meta->make_immutable;
+}
+
+is($attributes_applied, 4);
+
+done_testing;