6 use Test::More tests => 12;
15 package My::Attribute::Trait;
18 has 'alias_to' => (is => 'ro', isa => 'Str');
20 after 'install_accessors' => sub {
22 $self->associated_class->add_method(
24 $self->get_read_method_ref
34 traits => [qw/My::Attribute::Trait/],
47 my $c = My::Class->new(bar => 100);
48 isa_ok($c, 'My::Class');
50 is($c->bar, 100, '... got the right value for bar');
51 is($c->gorch, 10, '... got the right value for gorch');
54 is($c->baz, 100, '... got the right value for baz');
56 my $bar_attr = $c->meta->get_attribute('bar');
57 does_ok($bar_attr, 'My::Attribute::Trait');
58 ok($bar_attr->has_applied_traits, '... got the applied traits');
59 is_deeply($bar_attr->applied_traits, [qw/My::Attribute::Trait/], '... got the applied traits');
61 my $gorch_attr = $c->meta->get_attribute('gorch');
62 ok(!$gorch_attr->does('My::Attribute::Trait'), '... gorch doesnt do the trait');
63 ok(!$gorch_attr->has_applied_traits, '... no traits applied');
64 is($gorch_attr->applied_traits, undef, '... no traits applied');