bump version to 0.91
[gitmo/Moose.git] / t / 050_metaclasses / 013_metaclass_traits.t
index 9a32641..9211f33 100644 (file)
@@ -3,7 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 28;
+use lib 't/lib', 'lib';
+
+use Test::More tests => 32;
 use Test::Exception;
 
 {
@@ -171,9 +173,6 @@ is( Role::Foo->meta()->simple(), 5,
           '... and error provides a useful explanation' );
 }
 
-SKIP:
-{
-    skip 'This will blow up until Moose::Meta::Class->_fix_metaclass_incompatibility understands roles', 5;
 {
     package Foo::Subclass;
 
@@ -190,4 +189,34 @@ is( Foo::Subclass->meta()->simple2(), 55,
 can_ok( Foo::Subclass->meta(), 'attr2' );
 is( Foo::Subclass->meta()->attr2(), 'something',
     'Foo::Subclass->meta()->attr2() returns expected value' );
+
+{
+
+    package Class::WithAlreadyPresentTrait;
+    use Moose -traits => 'My::SimpleTrait';
+
+    has an_attr => ( is => 'ro' );
+}
+
+lives_ok {
+    my $instance = Class::WithAlreadyPresentTrait->new( an_attr => 'value' );
+    is( $instance->an_attr, 'value', 'Can get value' );
+}
+'Can create instance and access attributes';
+
+{
+
+    package Class::WhichLoadsATraitFromDisk;
+
+    # Any role you like here, the only important bit is that it gets
+    # loaded from disk and has not already been defined.
+    use Moose -traits => 'Role::Parent';
+
+    has an_attr => ( is => 'ro' );
+}
+
+lives_ok {
+    my $instance = Class::WhichLoadsATraitFromDisk->new( an_attr => 'value' );
+    is( $instance->an_attr, 'value', 'Can get value' );
 }
+'Can create instance and access attributes';