summaryrefslogtreecommitdiff
path: root/ext/List
diff options
context:
space:
mode:
authorFergal Daly <fergal@esatclear.ie>2003-12-02 23:18:18 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-12-25 18:59:54 +0000
commite6469971c726b88fe545b74db248847f2ef9b3e3 (patch)
tree8495fcc4e348e790d6dc1be1998cbe15a39ddee5 /ext/List
parentd83fac4511acd29416c2c1f375f9bae3da8e8d8b (diff)
downloadperl-e6469971c726b88fe545b74db248847f2ef9b3e3.tar.gz
[perl #24506] [PATCH] cannot weaken refs to read only values
Message-Id: <200312022318.18353.fergal@esatclear.ie> (tweaked so the test is skipped on perls < 5.9.0) p4raw-id: //depot/perl@21955
Diffstat (limited to 'ext/List')
-rwxr-xr-xext/List/Util/t/weak.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/ext/List/Util/t/weak.t b/ext/List/Util/t/weak.t
index 7941205793..d38c305e7f 100755
--- a/ext/List/Util/t/weak.t
+++ b/ext/List/Util/t/weak.t
@@ -35,7 +35,7 @@ BEGIN {
eval <<'EOT' unless $skip;
use Scalar::Util qw(weaken isweak);
-print "1..17\n";
+print "1..22\n";
######################### End of black magic.
@@ -44,6 +44,7 @@ $cnt = 0;
sub ok {
++$cnt;
if($_[0]) { print "ok $cnt\n"; } else {print "not ok $cnt\n"; }
+ return $_[0];
}
$| = 1;
@@ -205,6 +206,29 @@ weaken($x->{Y} = \$a);
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;