#!./perl
BEGIN {
chdir 't' if -d 't';
print "1..0 # Skip: List::Util was not built\n";
exit 0;
}
}
}
BEGIN {
$|=1;
print("1..0\n");
$skip=1;
}
$DEBUG = 0;
}
else {
*Dump = sub {};
}
}
print "1..22\n";
######################### End of black magic.
$cnt = 0;
sub ok {
++$cnt;
return $_[0];
}
$| = 1;
if(1) {
my ($y,$z);
#
# Case 1: two references, one is weakened, the other is then undef'ed.
#
{
my $x = "foo";
$y = \$x;
$z = \$x;
}
print "# START:\n";
print "# WEAK:\n";
print "# UNDZ:\n";
print "# UNDY:\n";
print "# FIN:\n";
# exit(0);
# }
# {
#
# Case 2: one reference, which is weakened
#
# kill 5,$$;
print "# CASE 2:\n";
{
my $x = "foo";
$y = \$x;
}
print "# BW: \n";
print "# AW: \n";
print "# EXITBLOCK\n";
}
# exit(0);
#
# Case 3: a circular structure
#
# kill 5, $$;
$flag = 0;
{
print "# 1: $y\n";
$y->{Self} = $y;
print "# 2: $y\n";
print "# 3: $y\n";
print "# WKED\n";
print "# VPRINT\n";
}
print "# AFTER\n";
print "# FLAGU\n";
#
# Case 4: a more complicated circular structure
#
$flag = 0;
{
$x->{Ref} = $y;
$y->{Ref} = $x;
}
#
# Case 5: deleting a weakref before the other one
#
{
my $x = "foo";
$y = \$x;
$z = \$x;
}
print "# CASE5\n";
#
# Case 6: test isweakref
#
$a = 5;
$b = \$a;
$b = \$a;
$x = {};
#
# Case 7: test weaken on a read only ref
#
if ($] < 5.008003) {
# Doesn't work for older perls, see bug [perl #24506]
print "# Skip next 5 tests on perl $]\n";
for (1..5) {
}
}
else {
$a = eval '\"hello"';
$b = $a;
# we didn't die
$a="";
}
sub DESTROY {
print "# INCFLAG\n";
${$_[0]{Flag}} ++;
}