diff options
author | James E Keenan <jkeenan@cpan.org> | 2019-09-19 23:02:54 -0400 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2019-10-09 19:02:03 +0000 |
commit | 01aed385e6bdbdcfd13bb66e9d8b7c55d2cfc34a (patch) | |
tree | 1e287fc0a8f78f7878f2567fbfb25ee8a87987b3 /dist/Dumpvalue/lib | |
parent | 17cc1736180b432c79ee3a8593d5e550b3d3a9ce (diff) | |
download | perl-01aed385e6bdbdcfd13bb66e9d8b7c55d2cfc34a.tar.gz |
Handle undefined values correctly
As reported by Henrik Pauli in RT 134441, the documentation's claim that
$dv->dumpValue([$x, $y]);
and
$dv->dumpValues($x, $y);
was not being sustained in the case where one of the elements in the
array (or array ref) was undefined. This was due to an insufficiently
precise specification within the dumpValues() method for determining
when the value "undef\n" should be printed.
Tests for previously untested cases have been provided in
t/rt-134441-dumpvalue.t. They were not appended to t/Dumpvalue.t (as
would normally have been the case) because the tests in that file have
accreted over the years in a sub-optimal manner: changes in attributes
of the Dumpvalue object are tested but those changes are not zeroed-out
(by, e.g., use of 'local $self->{attribute} = undef')
before additional attributes are modified and tested. As a consequence,
it's difficult to determine the state of the Dumpvalue object at any
particular point and interactions between attributes cannot be ruled
out.
Package TieOut, used to capture STDOUT during testing, has been
extracted to its own file so that it can be used by all test files.
Diffstat (limited to 'dist/Dumpvalue/lib')
-rw-r--r-- | dist/Dumpvalue/lib/Dumpvalue.pm | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/dist/Dumpvalue/lib/Dumpvalue.pm b/dist/Dumpvalue/lib/Dumpvalue.pm index eef9b27157..3faf829538 100644 --- a/dist/Dumpvalue/lib/Dumpvalue.pm +++ b/dist/Dumpvalue/lib/Dumpvalue.pm @@ -1,7 +1,7 @@ use 5.006_001; # for (defined ref) and $#$v and our package Dumpvalue; use strict; -our $VERSION = '1.18'; +our $VERSION = '1.19'; our(%address, $stab, @stab, %stab, %subs); sub ASCII { return ord('A') == 65; } @@ -79,7 +79,7 @@ sub dumpValues { my $self = shift; local %address; local $^W=0; - (print "undef\n"), return unless defined $_[0]; + (print "undef\n"), return if (@_ == 1 and not defined $_[0]); $self->unwrap(\@_,0); } |