reader => 'read_attr',
writer => 'write_attr',
);
+ has 'attr2' => (
+ is => 'rw',
+ accessor => 'rw_attr2',
+ );
};
with_immutable {
ok(!Class->can('x'), "No accessor is injected if 'is' has no value");
is $object->write_attr("piyo"), "piyo";
is $object->rw_attr("yopi"), "yopi";
+ can_ok $object, qw(rw_attr2);
+ ok !$object->can('attr2'), "doesn't have attr2";
+
dies_ok {
Class->rw_attr();
};
my @attrs = map { $_->name }
sort { $a->insertion_order <=> $b->insertion_order } $object->meta->get_all_attributes;
- is join(' ', @attrs), 'x y z attr', 'insertion_order';
+ is join(' ', @attrs), 'x y z attr attr2', 'insertion_order';
} qw(Class);
done_testing;
--- /dev/null
+#!perl
+#https://rt.cpan.org/Ticket/Display.html?id=61906
+use strict;
+use warnings;
+use Test::More;
+
+package MouseObj;
+use Mouse 0.78;
+
+has 'only_accessor' => (
+ is => 'rw',
+ isa => 'Int',
+ accessor => 'only_accessor_accessor',
+);
+
+has 'accesor_and_writer' => (
+ is => 'rw',
+ isa => 'Int',
+ accessor => 'accesor_and_writer_accessor',
+ writer => 'accesor_and_writer_writer',
+);
+
+has 'not_with_is' => (
+ isa => 'Int',
+ accessor => 'not_with_is_accessor',
+);
+
+package main;
+
+can_ok('MouseObj', 'only_accessor_accessor');
+can_ok('MouseObj', 'accesor_and_writer_accessor');
+can_ok('MouseObj', 'accesor_and_writer_writer');
+can_ok('MouseObj', 'not_with_is_accessor');
+
+done_testing;
else{
svp = hv_fetchs(args, "accessor", TRUE);
}
- sv_setsv(*svp, name);
+ if(!SvOK(*svp)) {
+ sv_setsv(*svp, name);
+ }
}
else if(strEQ(is, "bare")){
/* do nothing, but might complain later about missing methods */