9 has one => (is => 'ro', weak_ref => 1);
13 my $foo = Foo->new(one => $ref);
14 is($foo->one, $ref, 'value present');
15 ok(Scalar::Util::isweak($foo->{one}), 'value weakened');
17 ok (!defined $foo->{one}, 'weak value gone');
20 sub mk_ref { \ 'yay' };
21 my $foo_ro = eval { Foo->new(one => mk_ref()) };
25 qr/\QReference to readonly value in "one" can not be weakened on Perl < 5.8.3/,
26 'Expected exception thrown on old perls'
29 elsif ($^O eq 'cygwin' and $] < 5.012000) {
30 SKIP: { skip 'Static coderef reaping seems nonfunctional on cygwin < 5.12', 1 }
33 is(${$foo_ro->one},'yay', 'value present');
34 ok(Scalar::Util::isweak($foo_ro->{one}), 'value weakened');
36 { no warnings 'redefine'; *mk_ref = sub {} }
37 ok (!defined $foo_ro->{one}, 'optree reaped, ro static value gone');