1#!perl -w 2 3use strict; 4use Test::More tests => 1; 5use Test::LeakTrace qw(:test); 6 7 8{ 9 package X; 10 use Scalar::Util qw(weaken); 11 12 sub new{ 13 my($class) = @_; 14 15 my $self = bless {}, $class; 16 17 return $self; 18 } 19 20 sub set_other{ 21 my($self, $other) = @_; 22 weaken($self->{other} = $other) if $other; 23 return $self; 24 } 25} 26 27no_leaks_ok{ 28 my $a = X->new; 29 my $b = X->new; 30 31 $a->set_other($b); 32 $b->set_other($a); 33 34}; 35