2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
16 package My::Meta::Attribute::DefaultReadOnly;
19 extends 'Mouse::Meta::Attribute';
23 my ($self, $name, %options) = @_;
25 unless exists $options{is};
26 $next->($self, $name, %options);
31 package My::Attribute::Trait;
34 has 'alias_to' => (is => 'ro', isa => 'Str');
36 after 'install_accessors' => sub {
38 $self->associated_class->add_method(
40 $self->get_read_method_ref
50 metaclass => 'My::Meta::Attribute::DefaultReadOnly',
51 traits => [qw/My::Attribute::Trait/],
57 my $c = My::Class->new(bar => 100);
58 isa_ok($c, 'My::Class');
60 is($c->bar, 100, '... got the right value for bar');
63 is($c->baz, 100, '... got the right value for baz');
65 isa_ok($c->meta->get_attribute('bar'), 'My::Meta::Attribute::DefaultReadOnly');
66 does_ok($c->meta->get_attribute('bar'), 'My::Attribute::Trait');
67 is($c->meta->get_attribute('bar')->_is_metadata, 'ro', '... got the right metaclass customization');