From: Sawyer X Date: Fri, 20 Jul 2012 16:12:40 +0000 (+0300) Subject: add xt test for Moose + namespace::autoclean X-Git-Tag: v1.000001~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f139b7b6f213273cb230f5c08cfd54a763d0b9a;p=gitmo%2FMoo.git add xt test for Moose + namespace::autoclean --- diff --git a/xt/moose-autoclean-lazy-attr-builders.t b/xt/moose-autoclean-lazy-attr-builders.t new file mode 100644 index 0000000..7b3eb5c --- /dev/null +++ b/xt/moose-autoclean-lazy-attr-builders.t @@ -0,0 +1,31 @@ +use strict; +use warnings; +# when using an Moose object and namespace::autoclean +# lazy attributes that get a value on initialize still +# have their builders run + +{ + package MyMooseObject; + use Moose; +} + +{ + package BadObject; + use Moo; + # use MyMooseObject <- this is inferred here + use namespace::autoclean; + + has attr => ( is => 'lazy' ); + sub _build_attr {2} +} + +use Test::More; +# use BadObject <- this is inferred here + +is( + BadObject->new( attr => 1 )->attr, + 1, + q{namespace::autoclean doesn't run builders with default}, +); + +done_testing;