+0.00700
+ - Creating a new accessor with the same name as an old one would result in
+ a new attribute with no reader/writer/accessor. Reported by t0m
+ - tests (t0m)
0.00600 Dec 17, 2008
- Add test for a 'meta' accessor, which we need to treat as a
special case (t0m)
my $self = shift;
my $meta = $locate_metaclass->($self);
for my $attr_name (@_){
+ $meta->remove_attribute($attr_name)
+ if $meta->find_attribute_by_name($attr_name);
my $reader = $self->accessor_name_for($attr_name);
my $writer = $self->mutator_name_for( $attr_name);
my $self = shift;
my $meta = $locate_metaclass->($self);
for my $attr_name (@_){
+ $meta->remove_attribute($attr_name)
+ if $meta->find_attribute_by_name($attr_name);
my $reader = $self->accessor_name_for($attr_name);
my @opts = ($meta->has_method($reader) ? () : (reader => $reader) );
my $attr = $meta->add_attribute($attr_name, @opts);
my $self = shift;
my $meta = $locate_metaclass->($self);
for my $attr_name (@_){
+ $meta->remove_attribute($attr_name)
+ if $meta->find_attribute_by_name($attr_name);
my $writer = $self->mutator_name_for($attr_name);
my @opts = ($meta->has_method($writer) ? () : (writer => $writer) );
my $attr = $meta->add_attribute($attr_name, @opts);
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Test::More tests => 4;
+use Test::Exception;
+
+# 1
+use_ok('MooseX::Emulate::Class::Accessor::Fast');
+{
+ package My::Test::Package;
+ use Moose;
+ with 'MooseX::Emulate::Class::Accessor::Fast';
+ for (0..1) {
+ __PACKAGE__->mk_accessors(qw( foo ));
+ __PACKAGE__->mk_ro_accessors(qw( bar ));
+ __PACKAGE__->mk_wo_accessors(qw( baz ));
+ }
+}
+
+my $i = My::Test::Package->new(bar => 'bar');
+
+# 2
+lives_ok {
+ $i->foo('foo');
+ $i->baz('baz');
+
+ # 3-4
+ is($i->foo, 'foo');
+ is($i->bar, 'bar');
+} 'No exception';
+