diff options
author | David Mitchell <davem@iabyn.com> | 2010-05-04 14:37:04 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-05-04 14:45:54 +0100 |
commit | 191ad7eff570fc96c93993e4358f83e2033365d6 (patch) | |
tree | 84d1be60e8b381f8d501df4ebfdff755bea613f9 /t/op/local.t | |
parent | 5afa72af5aa99c40932771ad390abf5ba229611b (diff) | |
download | perl-191ad7eff570fc96c93993e4358f83e2033365d6.tar.gz |
make 'local $tied' untied
When localising a tied scalar, don't make the scalar tied
Diffstat (limited to 't/op/local.t')
-rw-r--r-- | t/op/local.t | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/t/op/local.t b/t/op/local.t index f664df4706..fababb7b8f 100644 --- a/t/op/local.t +++ b/t/op/local.t @@ -5,7 +5,7 @@ BEGIN { @INC = qw(. ../lib); require './test.pl'; } -plan tests => 306; +plan tests => 310; my $list_assignment_supported = 1; @@ -781,6 +781,33 @@ like( runperl(stderr => 1, 'index(q(a), foo);' . 'local *g=${::}{foo};print q(ok);'), "ok", "[perl #52740]"); +# localising a tied scalar should give you an untied var +{ + package TS; + sub TIESCALAR { bless \my $self, shift } + + my $s; + sub FETCH { $s .= ":F=${$_[0]}"; ${$_[0]} } + sub STORE { $s .= ":S($_[1])"; ${$_[0]} = $_[1]; } + + package main; + tie $ts, 'TS'; + $ts = 1; + { + $s .= ':L1'; + local $ts; + $s .= ':L2'; + is($ts, undef, 'local tied scalar initially undef'); + $ts = 2; + is($ts, 2, 'local tied scalar now has a value'); + $s .= ':E'; + } + is($ts, 1, 'restored tied scalar has correct value'); + $ts = 3; + is($s, ':S(1):L1:F=1:L2:E:F=1:S(3)', + "local tied scalar shouldn't call methods"); +} + # Keep this test last, as it can SEGV { local *@; |