Subject: | [PATCH] t/Constant.t: internal script throws 2 "earlier declaration in same scope" warnings |
In the ExtUtils-Constant distribution (CPAN version 0.25), test file t/Constant.t internally constructs a Perl program, 'test.pl', which, when run, emits a warning when run in an environment where warnings are on by default (as they may very well be in a future version of Perl).
You can see this by editing t/Constant.t as follows:
#####
$ diff -u t/Constant.t t/Constant-adapted.t
--- t/Constant.t 2020-10-10 13:44:22.780040370 -0400
+++ t/Constant-adapted.t 2020-10-10 13:45:11.165258751 -0400
@@ -445,6 +445,7 @@
# Standard test header (need an option to suppress this?)
print FH <<"EOT" or die $!;
use strict;
+use warnings;
use $package qw(@$export_names);
print "1..2\n";
#####
If you then build the distribution and run t/Constant.t in a typical manner, you get:
#####
$ perl Makefile.PL && make
$ prove -vb t/Constant-adapted.t
...
ok 63
ok 64 # This is dynamic linking, so no need to make perl
# make = 'make test'
"my" variable $error masks earlier declaration in same scope at test.pl line 58.
"my" variable $got masks earlier declaration in same scope at test.pl line 58.
# "perl" => 'rules'
ok 65
#####
This can be fixed with the patch attached, extutils-constant-t-constant.diff, which also corrects one spelling error in a test description.
Thank you very much.
Jim Keenan
Subject: | extutils-constant-t-constant.diff |
--- t/Constant.t 2020-10-10 13:44:22.780040370 -0400
+++ t/Constant-corrected.t 2020-10-10 13:54:47.337833213 -0400
@@ -445,6 +445,7 @@
# Standard test header (need an option to suppress this?)
print FH <<"EOT" or die $!;
use strict;
+use warnings;
use $package qw(@$export_names);
print "1..2\n";
@@ -904,7 +905,7 @@
}
EOT
- $test_body .= "my (\$error, \$got) = ${package}::constant (\$string);\n";
+ $test_body .= "(\$error, \$got) = ${package}::constant (\$string);\n";
$test_body .= <<'EOT';
if ($error or $got ne $expect) {
@@ -1024,7 +1025,7 @@
# I felt was rather too many. So I used words with 2 vowels.
simple ("Twos and three middle", qw(aa ae ai ea eu ie io oe era eta));
# Given the choice go for the end, else the earliest point
-simple ("Three end and four symetry", qw(ean ear eat barb marm tart));
+simple ("Three end and four symmetry", qw(ean ear eat barb marm tart));
# Need this if the single test below is rolled into @tests :