[perl #46893] [TODO] [Perl] Complete test coverage of Parrot::Test
James Keenan via RT
parrotbug-followup at parrotcode.org
Thu Dec 4 03:10:18 UTC 2008
On Thu Nov 27 10:59:57 2008, jkeen at verizon.net wrote:
> 'testparrottest' branch has been opened in SVN to hold this work.
This is a Perl 5 question pertaining to Parrot::Test. In my attempts to
improve the coverage of this module by t/perl/Parrot_Test.t, I have
learned that so far sub _report_odd_hash() is not tested at all. In
order to model how this works, I've extracted that sub and what seem to
be other essentials into a separate file, odd_hash.pl (attached).
When I run 'perl odd_hash.pl', this is the output I get:
Odd 22 invocation; probably missing description for TODO test at
odd_hash.pl line 33
main::_report_odd_hash('Odd number of elements in hash
assignment at odd_hash.pl line...') called at odd_hash.pl line 22
main::golden() called at odd_hash.pl line 18
This does not seem to DWIM. In particular, that '22' in the first line
of output is not helpful. Given that the variable there is '$func', I
would presume the author of this code was expecting the name of a
subroutine to be displayed there. Instead you get a line number --
which is at least consistent with the documentation for 'caller':
# 0 1 2
($package, $filename, $line) = caller;
In addition, nothing is ever done with the '@args' inside
_report_odd_hash():
my @args = DB::uplevel_args();
shift @args;
Since, in our current tests, _report_odd_hash() is never invoked, I
don't have any use cases to look at. And that leads me to believe that
we don't need sub _report_odd_hash() at all, since its purpose only
seems to be to provide a smidgen of an explanation more than you get
with Perl's regular warning/error message.
Does anyone see something here that I'm missing?
Thank you very much.
kid51
-------------- next part --------------
package DB;
use strict;
use warnings;
sub uplevel_args {
my @foo = caller(2);
return @DB::args;
}
1;
package main;
use strict;
use warnings;
use Data::Dumper;
golden();
sub golden {
local $SIG{__WARN__} = \&_report_odd_hash;
my %badhash = ( 'alpha' => 'beta', 'gamma' );
}
sub _report_odd_hash {
my $warning = shift;
if ( $warning =~ m/Odd number of elements in hash assignment/ ) {
require Carp;
my @args = DB::uplevel_args();
shift @args;
my $func = ( caller() )[2];
Carp::carp("Odd $func invocation; probably missing description for TODO test");
}
else {
warn $warning;
}
}
More information about the parrot-dev
mailing list