summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-06-15 11:41:57 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-07-25 23:47:58 -0700
commit7f6ba6d234ccc0e3e085c7f74151d287c91be0b9 (patch)
tree0929e68873dbb63726dfca59f3e357088cad9388
parent6f7e3040169a31244d7459c4fa0492602bc514df (diff)
downloadperl-7f6ba6d234ccc0e3e085c7f74151d287c91be0b9.tar.gz
sub.t: To-do test for recursive shared-hash-keys TARGs
This is only buggy under ithreads. sub a { for (${\""}.${\""}) { $_ = $_[0] || __PACKAGE__; print "$_\n"; a("road") unless $_[0]; print "$_\n"; } } a(); The outer call sets the scalar returned by ${\""}.${\""} to the cur- rent package name. The inner call sets it to "road". Each call prints it twice, the outer call surrounding the inner call. The output in 5.10-5.18 is: main road road road because the inner call is clobbering the same scalar. If __PACKAGE__ is changed to "main", it works, and prints main road road main (as the script above also prints in 5.8.8).
-rw-r--r--t/op/sub.t25
1 files changed, 24 insertions, 1 deletions
diff --git a/t/op/sub.t b/t/op/sub.t
index c4121dfda1..e00f26f415 100644
--- a/t/op/sub.t
+++ b/t/op/sub.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan( tests => 16 );
+plan( tests => 17 );
sub empty_sub {}
@@ -85,3 +85,26 @@ undef *foo;
undef *bar;
print "ok\n";
end
+
+# The outer call sets the scalar returned by ${\""}.${\""} to the current
+# package name.
+# The inner call sets it to "road".
+# Each call records the value twice, the outer call surrounding the inner
+# call. In 5.10-5.18 under ithreads, what gets pushed is
+# qw(main road road road) because the inner call is clobbering the same
+# scalar. If __PACKAGE__ is changed to "main", it works, the last element
+# becoming "main".
+my @scratch;
+sub a {
+ for (${\""}.${\""}) {
+ $_ = $_[0];
+ push @scratch, $_;
+ a("road",1) unless $_[1];
+ push @scratch, $_;
+ }
+}
+a(__PACKAGE__);
+require Config;
+$::TODO = "not fixed yet" if $Config::Config{useithreads};
+is "@scratch", "main road road main",
+ 'recursive calls do not share shared-hash-key TARGs';