diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-09-02 19:01:07 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-09-02 19:01:07 +0000 |
commit | 16e0ce555006838e58e7d577abeb6130585428b8 (patch) | |
tree | 5c1e5b6603ccf89b83e669fbda5cc238570d2767 /t/op/tie.t | |
parent | 35f1c1c77f660b910b6112c847a62b8d3cd3b402 (diff) | |
download | perl-16e0ce555006838e58e7d577abeb6130585428b8.tar.gz |
An untie test from perlmonks-- worked in 5.6.1,
broken in 5.8.0, seems to be working again in maint,
better nail it down now.
p4raw-id: //depot/perl@21003
Diffstat (limited to 't/op/tie.t')
-rwxr-xr-x | t/op/tie.t | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/op/tie.t b/t/op/tie.t index d73cce1555..7e45615aff 100755 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -367,3 +367,41 @@ my $var; tie $var, 'main', \$var; untie $var; EXPECT +######## +# Test case from perlmonks by runrig +# http://www.perlmonks.org/index.pl?node_id=273490 +# "Here is what I tried. I think its similar to what you've tried +# above. Its odd but convienient that after untie'ing you are left with +# a variable that has the same value as was last returned from +# FETCH. (At least on my perl v5.6.1). So you don't need to pass a +# reference to the variable in order to set it after the untie (here it +# is accessed through a closure)." +use strict; +use warnings; +package MyTied; +sub TIESCALAR { + my ($class,$code) = @_; + bless $code, $class; +} +sub FETCH { + my $self = shift; + print "Untie\n"; + $self->(); +} +package main; +my $var; +tie $var, 'MyTied', sub { untie $var; 4 }; +print "One\n"; +print "$var\n"; +print "Two\n"; +print "$var\n"; +print "Three\n"; +print "$var\n"; +EXPECT +One +Untie +4 +Two +4 +Three +4 |