use strict;
use warnings;
use Test::More tests => 10;
+use Test::Exception;
do {
package Class;
can_ok($object, 'y', 'z');
is($object->y, undef);
-is($object->y(10), undef);
+
+throws_ok {
+ $object->y(10);
+} qr/Cannot assign a value to a read-only accessor/;
+
is($object->y, undef);
is($object->z, undef);