use Test::Requires in tests
[gitmo/Moose.git] / t / 020_attributes / 009_attribute_inherited_slot_specs.t
index 7903f9d..71bc254 100644 (file)
@@ -3,12 +3,19 @@
 use strict;
 use warnings;
 
-use Test::More tests => 84;
+use Test::More;
 use Test::Exception;
 
 
-
 {
+    package Thing::Meta::Attribute;
+    use Moose;
+
+    extends 'Moose::Meta::Attribute';
+    around illegal_options_for_inheritance => sub {
+        return (shift->(@_), qw/trigger/);
+    };
+
     package Thing;
     use Moose;
 
@@ -33,6 +40,7 @@ use Test::Exception;
 
     has 'gorch' => (is => 'ro');
     has 'gloum' => (is => 'ro', default => sub {[]});
+    has 'fleem' => (is => 'ro');
 
     has 'bling' => (is => 'ro', isa => 'Thing');
     has 'blang' => (is => 'ro', isa => 'Thing', handles => ['goodbye']);
@@ -43,7 +51,7 @@ use Test::Exception;
 
     # this one will work here ....
     has 'fail' => (isa => 'CodeRef', is => 'bare');
-    has 'other_fail' => (is => 'bare');
+    has 'other_fail' => (metaclass => 'Thing::Meta::Attribute', is => 'bare', trigger => sub { });
 
     package Bar;
     use Moose;
@@ -88,6 +96,10 @@ use Test::Exception;
     } '... now can extend an attribute with a non-subtype';
 
     ::lives_ok {
+        has '+fleem' => (weak_ref => 1);
+    } '... now allowed to add the weak_ref option via inheritance';
+
+    ::lives_ok {
         has '+bling' => (handles => ['hello']);
     } '... we can add the handles attribute option';
 
@@ -101,9 +113,6 @@ use Test::Exception;
     ::dies_ok {
         has '+other_fail' => (trigger => sub {});
     } '... cannot create an attribute with an illegal option';
-    ::dies_ok {
-        has '+other_fail' => (weak_ref => 1);
-    } '... cannot create an attribute with an illegal option';
     ::throws_ok {
         has '+does_not_exist' => (isa => 'Str');
     } qr/in Bar/, '... cannot extend a non-existing attribute';
@@ -259,4 +268,4 @@ ok(!Foo->meta->get_attribute('bling')->has_handles,
 ok(Bar->meta->get_attribute('bling')->has_handles,
    '... Bar::foo should handles');
 
-
+done_testing;