From: Andrew Rodland Date: Sat, 17 Mar 2012 20:33:18 +0000 (-0400) Subject: Test that lazy defaults get coerced the same as non-lazy ones X-Git-Tag: v0.009014~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c1bf1b09e590a486460048aeec5305909cde191;p=gitmo%2FMoo.git Test that lazy defaults get coerced the same as non-lazy ones --- diff --git a/t/accessor-coerce.t b/t/accessor-coerce.t index 7533ada..804a3d0 100644 --- a/t/accessor-coerce.t +++ b/t/accessor-coerce.t @@ -168,5 +168,38 @@ run_with_default_for 'Baz2'; like exception { Biff2->new() }, qr/could not add three!/, 'Exception properly thrown'; +{ + package Foo3; + + use Moo; + + has plus_three => ( + is => 'rw', + default => sub { 1 }, + coerce => sub { $_[0] + 3 }, + lazy => 1, + ); +} + +run_with_default_for 'Foo3'; + +{ + package Bar3; + + use Sub::Quote; + use Moo; + + has plus_three => ( + is => 'rw', + default => sub { 1 }, + coerce => quote_sub q{ + my ($x) = @_; + $x + 3 + }, + lazy => 1, + ); +} + +run_with_default_for 'Bar3'; done_testing;