From: Andrew Rodland Date: Sat, 17 Mar 2012 21:30:26 +0000 (-0400) Subject: Test that triggers don't fire for attr default values (lazy or not) X-Git-Tag: v0.009014~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3fc078d5269f1d5c068aae2356472cedb307d0c0;p=gitmo%2FMoo.git Test that triggers don't fire for attr default values (lazy or not) This is consistent with what's documented in Moose perldoc --- diff --git a/t/accessor-trigger.t b/t/accessor-trigger.t index 632819e..4728395 100644 --- a/t/accessor-trigger.t +++ b/t/accessor-trigger.t @@ -62,4 +62,35 @@ run_for 'Bar'; run_for 'Baz'; +{ + package Default; + + use Sub::Quote; + use Moo; + + has one => ( + is => 'rw', + trigger => quote_sub(q{ push @{$tr}, $_[1] }, { '$tr' => \\@::tr }), + default => sub { 0 } + ); +} + +run_for 'Default'; + +{ + package LazyDefault; + + use Sub::Quote; + use Moo; + + has one => ( + is => 'rw', + trigger => quote_sub(q{ push @{$tr}, $_[1] }, { '$tr' => \\@::tr }), + default => sub { 0 }, + lazy => 1 + ); +} + +run_for 'LazyDefault'; + done_testing;