From: Graham Knop Date: Mon, 24 Jun 2013 04:49:16 +0000 (-0400) Subject: tests for combining lazy/rwp with reader/writer X-Git-Tag: v1.003000~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0d931f8a92552b142000bd5a4886e0c3d7d1a553;p=gitmo%2FMoo.git tests for combining lazy/rwp with reader/writer --- diff --git a/t/accessor-reader-writer.t b/t/accessor-reader-writer.t index 04c0000..6185eb4 100644 --- a/t/accessor-reader-writer.t +++ b/t/accessor-reader-writer.t @@ -16,6 +16,18 @@ my @result; ); sub one {'sub'} + + has two => ( + is => 'lazy', + default => sub { 2 }, + reader => 'get_two', + ); + + has three => ( + is => 'rwp', + reader => 'get_three', + writer => 'set_three', + ); } { @@ -37,6 +49,13 @@ $foo->set_one('rofl'); is( $foo->get_one, 'rofl', 'writer works' ); is( $foo->one, 'sub', 'reader+writer = no accessor' ); +is( $foo->get_two, 2, 'lazy doesn\'t override reader' ); + +is( $foo->can('two'), undef, 'reader+ro = no accessor' ); + +ok( $foo->can('get_three'), 'rwp doesn\'t override reader'); +ok( $foo->can('set_three'), 'rwp doesn\'t override writer'); + ok( exception { $foo->get_one('blah') }, 'reader dies on write' ); is( $bar->TWO, '...', 'accessor works for reading' );