eval <<'EOT' unless $skip;
use Scalar::Util qw(weaken isweak);
-print "1..17\n";
+print "1..22\n";
######################### End of black magic.
sub ok {
++$cnt;
if($_[0]) { print "ok $cnt\n"; } else {print "not ok $cnt\n"; }
+ return $_[0];
}
$| = 1;
ok(isweak($x->{Y}));
ok(!isweak($x->{Z}));
+#
+# Case 7: test weaken on a read only ref
+#
+
+if ($] < 5.009) {
+ # Doesn't work for older perls, see bug [perl #24506]
+ print "# Skip next 5 tests on perl $]\n";
+ for (1..5) {
+ ok(1);
+ }
+}
+else {
+ $a = eval '\"hello"';
+ ok(ref($a)) or print "# didn't get a ref from eval\n";
+ $b = $a;
+ eval{weaken($b)};
+ # we didn't die
+ ok($@ eq "") or print "# died with $@\n";
+ ok(isweak($b));
+ ok($$b eq "hello") or print "# b is '$$b'\n";
+ $a="";
+ ok(not $b) or print "# b didn't go away\n";
+}
package Dest;