X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Flocal.t;h=8bfea00b9a4006b5b7fe19f5d58dd0d63b5fe82b;hb=21fa6956243df9cb622bebfa0934ea7923519b4f;hp=5aea9672806536255260b5f2d039cc5e0f424d88;hpb=28e491ba9090286e45cbf77736b31eecb771fe4e;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/local.t b/t/op/local.t index 5aea967..8bfea00 100755 --- a/t/op/local.t +++ b/t/op/local.t @@ -5,7 +5,7 @@ BEGIN { @INC = qw(. ../lib); require './test.pl'; } -plan tests => 114; +plan tests => 122; my $list_assignment_supported = 1; @@ -428,3 +428,37 @@ sub f { ok(0 == $[); } } +# when localising a hash element, the key should be copied, not referenced + +{ + my %h=('k1' => 111); + my $k='k1'; + { + local $h{$k}=222; + + is($h{'k1'},222); + $k='k2'; + } + ok(! exists($h{'k2'})); + is($h{'k1'},111); +} +{ + my %h=('k1' => 111); + our $k = 'k1'; # try dynamic too + { + local $h{$k}=222; + is($h{'k1'},222); + $k='k2'; + } + ok(! exists($h{'k2'})); + is($h{'k1'},111); +} + +# Keep this test last, as it can SEGV +{ + local *@; + pass("Localised *@"); + eval {1}; + pass("Can eval with *@ localised"); +} +