From: Arthur Axel 'fREW' Schmidt Date: Thu, 11 Nov 2010 04:37:58 +0000 (-0600) Subject: Test for reader/writer/accessor X-Git-Tag: 0.009001~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68a51c0010322ed330838b455460d2774abdbf39;p=gitmo%2FMoo.git Test for reader/writer/accessor --- diff --git a/t/accessor-reader-writer.t b/t/accessor-reader-writer.t new file mode 100644 index 0000000..da0ef89 --- /dev/null +++ b/t/accessor-reader-writer.t @@ -0,0 +1,40 @@ +use strictures 1; +use Test::More; + +my @result; + +{ + package Foo; + + use Moo; + + has one => ( + is => 'rw', + reader => 'get_one', + writer => 'set_one', + ); +} + +{ + package Bar; + + use Moo; + + has two => ( + is => 'rw', + accessor => 'TWO', + ); +} + +my $foo = Foo->new(one => 'lol'); +my $bar = Bar->new(two => '...'); + +is( $foo->get_one, 'lol', 'reader works' ); +$foo->set_one('rofl'); +is( $foo->get_one, 'rofl', 'writer works' ); + +is( $bar->TWO, '...', 'accessor works for reading' ); +$bar->TWO('!!!'); +is( $bar->TWO, '!!!', 'accessor works for writing' ); + +done_testing;