' my $default; '.
' $default = $attr->default(' . $inv . ') if $attr->has_default;' .
' if ( $attr->has_builder ) { '.
- ' my $builder = $self->builder;'.
+ ' my $builder = $attr->builder;'.
' if($builder = '.$inv.'->can($builder)){ '.
' $default = '.$inv.'->$builder; '.
' } else { '.
'|| confess "Attribute (' . $attr->name . ') is required";');
}
- if ($attr->has_default && !($is_moose &&$attr->is_lazy)) {
+ if ($attr->has_default && !($is_moose && $attr->is_lazy)) {
push @source => 'if (exists $params{\'' . $attr->init_arg . '\'}) {';
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More tests => 14;
use Test::Exception;
BEGIN {
package Foo;
use Moose;
+ #two checks because the inlined methods are different when
+ #there is a TC present.
has 'foos' => (is => 'ro', lazy_build => 1);
+ has 'bars' => (isa => 'Str', is => 'ro', lazy_build => 1);
sub _build_foos{ "many foos" }
-
+ sub _build_bars{ "many bars" }
}
{
lives_ok{ Foo->new } "lazy_build works";
is(Foo->new->foos, 'many foos' , "correct value for 'foos'");
+ is(Foo->new->bars, 'many bars' , "correct value for 'bars'");
lives_ok{ $meta->make_immutable } "Foo is imutable";
dies_ok{ $meta->add_role($foo_role) } "Add Role is locked";
lives_ok{ Foo->new } "Inlined constructor works with lazy_build";
is(Foo->new->foos, 'many foos' , "correct value for 'foos'");
+ is(Foo->new->bars, 'many bars' , "correct value for 'bars'");
lives_ok{ $meta->make_mutable } "Foo is mutable";
lives_ok{ $meta->add_role($foo_role) } "Add Role is unlocked";