Subtypes is one word
[gitmo/Moose.git] / t / 020_attributes / 016_attribute_traits_registered.t
index ad4aa84..01b9536 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 24;
 use Test::Exception;
 use Test::Moose;
 
@@ -39,7 +39,7 @@ BEGIN {
         42;
     };
 
-    has bar => ( isa => "Str", default => "oink" );
+    has the_other_attr => ( isa => "Str", is => "rw", default => "oink" );
 
     after 'install_accessors' => sub {
         my $self = shift;
@@ -88,6 +88,11 @@ my $bar_attr = $c->meta->get_attribute('bar');
 does_ok($bar_attr, 'My::Attribute::Trait');
 is($bar_attr->foo, "blah", "attr initialized");
 
+ok(!$bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
+ok($bar_attr->does('Aliased'), "attr->does uses aliases");
+ok(!$bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
+ok(!$bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
+
 my $quux = My::Derived::Class->new(bar => 1000);
 
 is($quux->bar, 1000, '... got the right value for bar');
@@ -100,12 +105,15 @@ does_ok($derived_bar_attr, 'My::Attribute::Trait' );
 
 is( $derived_bar_attr->foo, "blah", "attr initialized" );
 
-TODO: {
-    local $TODO = 'traits in clone_and_inherit dont work yet';
-    does_ok($derived_bar_attr, 'My::Other::Attribute::Trait' );
+does_ok($derived_bar_attr, 'My::Other::Attribute::Trait' );
 
-    is( eval { $derived_bar_attr->bar }, "oink", "attr initialized" );
+is($derived_bar_attr->the_other_attr, "oink", "attr initialized" );
+
+ok(!$derived_bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
+ok($derived_bar_attr->does('Aliased'), "attr->does uses aliases");
+ok(!$derived_bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
+ok(!$derived_bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
+
+can_ok($quux, 'additional_method');
+is(eval { $quux->additional_method }, 42, '... got the right value for additional_method');
 
-    can_ok($quux, 'additional_method');
-    is(eval { $quux->additional_method }, 42, '... got the right value for additional_method');
-}