> From: Pär Karlsson <address@hidden> > > A number of Perl-specific cleanups in the test suite perl modules. > > Most of these changes have no immediate functional difference but puts code > in line with the same formatting (perltidy GNU style) for readability. > > A warning regarding invalid operators on incompatible values (numeric vs > strings) have been fixed. > > Some common but discouraged Perl idioms have been updated to a somewhat > clearer style, especially regarding evals and map() vs. for loops. > > I did not touch the FTP and HTTP server modules functionally, but there seem > to be a lot of strange code there in, and would warrant further cleanups > and investigations if these tests would remain in Perl, instead of moving > over to the Python based tests. > > All tests work nominally on my machine (with perl-5.20.1) but should be > compatible with versions down to 5.6.
I believe I have found an issue with WgetTests module:
> my $i;
>
> # for ($i=0; $i != $min; ++$i) {
> for my $i (0 .. $min - 1)
> {
> last if substr($expected, $i, 1) ne substr $actual, $i, 1;
> if (substr($expected, $i, 1) eq q{\n})
> {
> $line++;
> $col = 0;
> }
> else
> {
> $col++;
> }
> }
> my $snip_start = $i - ($SNIPPET_SIZE / 2);
> if ($snip_start < 0)
> {
> $SNIPPET_SIZE += $snip_start; # Take it from the end.
> $snip_start = 0;
> }
I am no Perl expert but I tested it and current for loop will not set
the $i variable to any value (outside the loop). (Actually it gives me
warning about using uninitialized variable when calculating $snip_start
and the diff is not printed correctly.)
Reverting the commented version seems to fix this problem. Removing the
"my" from current for loop does not seem to fix the problem.
--
Hubert Tarasiuk
From b4eb2dd8ee7c0fbae81cfad29eb57c60dd96b587 Mon Sep 17 00:00:00 2001 From: Hubert Tarasiuk <[email protected]> Date: Tue, 19 May 2015 19:45:37 +0200 Subject: [PATCH] Repair buggy for loop in WgetTests.pm. * tests/WgetTests.pm (_show_diff): Revert commented for loop. --- tests/WgetTests.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/WgetTests.pm b/tests/WgetTests.pm index 501aeba..2cc6859 100644 --- a/tests/WgetTests.pm +++ b/tests/WgetTests.pm @@ -267,8 +267,7 @@ sub _show_diff my $col = 1; my $i; - # for ($i=0; $i != $min; ++$i) { - for my $i (0 .. $min - 1) + for ($i=0; $i != $min; ++$i) { last if substr($expected, $i, 1) ne substr $actual, $i, 1; if (substr($expected, $i, 1) eq q{\n}) -- 2.4.1
signature.asc
Description: OpenPGP digital signature
