diff options
author | James E Keenan <jkeenan@cpan.org> | 2020-03-01 16:56:57 -0500 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2020-03-01 17:19:57 -0500 |
commit | 125e1a36a9395a6da73708bbeb316350fdfe2722 (patch) | |
tree | ad71909309ee4dd3ab9373cb580a41209fd6b4ce | |
parent | 0108ded06b75d7cd668faeaf9ade081ce59c1714 (diff) | |
download | perl-125e1a36a9395a6da73708bbeb316350fdfe2722.tar.gz |
undef Tie::File objects before untie-ing arrays
This test file was added before we converted all .pm and .t files under
dist/Tie-File to 'use strict' and 'use warnings'. So at that point the
test ran without warnings. Once we subsequently began to run with
warnings, we failed to note two instances of "untie attempted while 1
inner references still exist" warnings. So we should undef the
Tie::File objects before calling 'untie' on the arrays holding records
of tied files.
(Indeed, undef-ing the Tie::File objects may in itself be sufficient to
avert these warnings. However, the pre-existing SYNOPSIS shows use of
'untie', so we'll include it in this file, whose point is to test what
is asserted in that document.)
-rw-r--r-- | dist/Tie-File/t/43_synopsis.t | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/dist/Tie-File/t/43_synopsis.t b/dist/Tie-File/t/43_synopsis.t index 56688493ef..904d9cd8a4 100644 --- a/dist/Tie-File/t/43_synopsis.t +++ b/dist/Tie-File/t/43_synopsis.t @@ -146,9 +146,9 @@ $desc = "got expected element"; : print "not ok $N - $desc\n"; $N++; +$o = undef; # destroy Tie::File object holding file open # Untie the first file my $u = untie @array; -$o = undef; # destroy object holding file open # TODO: perldoc -f untie does not specify return value for untie open my $G, "<", $file or die "Unable to open $file for reading: $!"; @@ -195,10 +195,10 @@ $desc = "last element in dupe array corresponds to last line of dupe file"; $N++; END { - untie @array; - untie @dupe; undef $o; undef $p; + untie @array; + untie @dupe; 1 while unlink $file; 1 while unlink $dupe; } |