my $mi = $self->associated_class->get_meta_instance;
return (
- $mi->inline_weaken_slot_value($instance, $self->name, $value),
+ $mi->inline_weaken_slot_value($instance, $self->name),
'if ref ' . $value . ';',
);
}
$value = $self->_coerce_and_verify( $value, $instance );
$self->set_initial_value($instance, $value);
+
+ if ( ref $value && $self->is_weak_ref ) {
+ $self->_weaken_value($instance);
+ }
}
}
$self->_inline_check_constraint($default, $tc, $message, $for_lazy))
: (),
$self->_inline_init_slot($instance, $default),
+ $self->_inline_weaken_value($instance, $default),
);
}
};
::ok(!$@, '... created the lazy reader method okay') or warn $@;
+ eval {
+ has 'lazy_weak_foo' => (
+ reader => 'get_lazy_weak_foo',
+ lazy => 1,
+ default => sub { our $AREF = [] },
+ weak_ref => 1,
+ );
+ };
+ ::ok(!$@, '... created the lazy weak reader method okay') or warn $@;
+
my $warn;
eval {
isnt( exception {
$foo->get_lazy_foo(100);
}, undef, '... get_lazy_foo is a read-only' );
+
+ is($foo->get_lazy_weak_foo(), $Foo::AREF, 'got the right value');
+ ok($foo->meta->get_meta_instance->slot_value_is_weak($foo, 'lazy_weak_foo'),
+ '... and it is weak');
}
{
is( $attr->get_value($foo), 10, "lazy value" );
is( $attr->get_raw_value($foo), 10, "raw value" );
+
+ my $lazy_weak_attr = $foo->meta->find_attribute_by_name("lazy_weak_foo");
+
+ is( $lazy_weak_attr->get_value($foo), $Foo::AREF, "it's the right value" );
+
+ ok( $foo->meta->get_meta_instance->slot_value_is_weak($foo, 'lazy_weak_foo'), "and it is weak");
}
{