chdir 't' if -d 't';
require './test.pl';
}
-plan tests => 95;
+plan tests => 114;
my $list_assignment_supported = 1;
::ok(f1() eq "f1", "localised sub restored");
{
local @Other::{qw/ f1 f2 /} = (sub { "j1" }, sub { "j2" });
- local $::TODO = "localisation of stash slice not working";
::ok(f1() eq "j1", "localised sub via stash slice");
::ok(f2() eq "j2", "localised sub via stash slice");
- undef $::TODO;
}
::ok(f1() eq "f1", "localised sub restored");
::ok(f2() eq "f2", "localised sub restored");
}
+
+# Localising unicode keys (bug #38815)
+{
+ my %h;
+ $h{"\243"} = "pound";
+ $h{"\302\240"} = "octects";
+ is(scalar keys %h, 2);
+ {
+ my $unicode = chr 256;
+ my $ambigous = "\240" . $unicode;
+ chop $ambigous;
+ local $h{$unicode} = 256;
+ local $h{$ambigous} = 160;
+
+ is(scalar keys %h, 4);
+ is($h{"\243"}, "pound");
+ is($h{$unicode}, 256);
+ is($h{$ambigous}, 160);
+ is($h{"\302\240"}, "octects");
+ }
+ is(scalar keys %h, 2);
+ is($h{"\243"}, "pound");
+ is($h{"\302\240"}, "octects");
+}
+
+# And with slices
+{
+ my %h;
+ $h{"\243"} = "pound";
+ $h{"\302\240"} = "octects";
+ is(scalar keys %h, 2);
+ {
+ my $unicode = chr 256;
+ my $ambigous = "\240" . $unicode;
+ chop $ambigous;
+ local @h{$unicode, $ambigous} = (256, 160);
+
+ is(scalar keys %h, 4);
+ is($h{"\243"}, "pound");
+ is($h{$unicode}, 256);
+ is($h{$ambigous}, 160);
+ is($h{"\302\240"}, "octects");
+ }
+ is(scalar keys %h, 2);
+ is($h{"\243"}, "pound");
+ is($h{"\302\240"}, "octects");
+}
+
+# [perl #39012] localizing @_ element then shifting frees element too # soon
+
+{
+ my $x;
+ my $y = bless [], 'X39012';
+ sub X39012::DESTROY { $x++ }
+ sub { local $_[0]; shift }->($y);
+ ok(!$x, '[perl #39012]');
+
+}
+