4 use Test::More tests => 15;
24 accessor => 'rw_attr',
25 reader => 'read_attr',
26 writer => 'write_attr',
30 ok(!Class->can('x'), "No accessor is injected if 'is' has no value");
31 can_ok('Class', 'y', 'z');
33 my $object = Class->new;
35 ok(!$object->can('x'), "No accessor is injected if 'is' has no value");
36 can_ok($object, 'y', 'z');
38 is($object->y, undef);
42 } qr/Cannot assign a value to a read-only accessor/;
44 is($object->y, undef);
46 is($object->z, undef);
47 is($object->z(10), 10);
50 can_ok($object, qw(rw_attr read_attr write_attr));
51 $object->write_attr(42);
52 is $object->rw_attr, 42;
53 is $object->read_attr, 42;
54 $object->rw_attr(100);
55 is $object->rw_attr, 100;
56 is $object->read_attr, 100;