[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH] Stylistic and idiomatic cleanups in Perl tests

From: Hubert Tarasiuk
Subject: Re: [Bug-wget] [PATCH] Stylistic and idiomatic cleanups in Perl tests
Date: Tue, 19 May 2015 20:04:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

> 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

Attachment: 0001-Repair-buggy-for-loop-in-WgetTests.pm.patch
Description: Text Data

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]