From: Ricardo SIGNES Date: Fri, 5 Dec 2008 01:12:59 +0000 (+0000) Subject: reader/writer X-Git-Tag: 0.19~142 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=41ceffa1107ad852cba2f1eafaceb9708a38747c;p=gitmo%2FMouse.git reader/writer --- diff --git a/t/033-readwrite.t b/t/033-readwrite.t new file mode 100644 index 0000000..a3db4c7 --- /dev/null +++ b/t/033-readwrite.t @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 4; +use Mouse::Util ':test'; + +do { + package Class; + use Mouse; + + # We want this attr to have a reader and writer with unconventional names, + # and not the default rw_attr method. -- rjbs, 2008-12-04 + has 'rw_attr' => ( + reader => 'read_attr', + writer => 'write_attr', + );; +}; + +my $object = Class->new; + +ok(!$object->can('rw_attr'), "no rw_attr method because wasn't 'is' ro or rw"); +ok($object->can('read_attr'), "did get a reader"); +ok($object->can('write_attr'), "did get a writer"); + +$object->write_attr(2); + +is($object->read_attr, 2, "writing to the object worked"); +