Subject: | Weird behavior in lazy_build |
# Weird behavior in lazy_build
# perl v5.12.1
# Moose 1.15
package Foo;
use Moose;
has 'foo' => ( is => 'ro' );
has 'bar' => ( is => 'ro' );
has 'baz' => ( is => 'ro' );
has 'quux' => ( is => 'ro' , lazy_build => 1);
package Bar;
use Moose;
extends 'Foo';
has '+foo' => ( lazy => 1, builder => '_build_foo' );
has '+bar' => ( default => 'whoa!' );
has '+baz' => ( lazy_build => 1 );
sub _build_foo {
return 'bla';
}
sub _build_baz {
return 'woof!';
}
sub _build_quux {
return 'meow!';
}
package main;
use Test::More;
my $bar = Bar->new;
is( $bar->foo, 'bla' );
is( $bar->bar, 'whoa!' );
is( $bar->baz, 'woof!', 'weird...' ); # !?
is( $bar->quux, 'meow!');
done_testing;