9 if (grep { /weaken/ } @Scalar::Util::EXPORT_FAIL) {
16 if ($DEBUG && eval { require Devel::Peek } ) {
17 Devel::Peek->import('Dump');
24 use Scalar::Util qw(weaken isweak);
27 ######################### End of black magic.
33 if($_[0]) { print "ok $cnt\n"; } else {print "not ok $cnt\n"; }
43 # Case 1: two references, one is weakened, the other is then undef'ed.
54 ok( $y ne "" and $z ne "" );
60 ok( $y ne "" and $z ne "" );
66 ok( not (defined($y) and defined($z)) );
72 ok( not (defined($y) and defined($z)) );
83 # Case 2: one reference, which is weakened
101 ok( not defined $y );
103 print "# EXITBLOCK\n";
109 # Case 3: a circular structure
116 my $y = bless {}, Dest;
127 print "# VALS: HASH ",$y," SELF ",\$y->{Self}," Y ",\$y,
128 " FLAG: ",\$y->{Flag},"\n";
131 print "# OUT $flag\n";
141 # Case 4: a more complicated circular structure
146 my $y = bless {}, Dest;
147 my $x = bless {}, Dest;
157 # Case 5: deleting a weakref before the other one
178 # Case 6: test isweakref
191 weaken($x->{Y} = \$a);
193 ok(!isweak($x->{Z}));