Skip to content

Commit 4948177

Browse files
committed
Enforce strict on testsuite
1 parent 4ba2ad0 commit 4948177

12 files changed

+45
-22
lines changed

Diff for: t/00impl-pp.t

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More qw/no_plan/;
89
use File::Spec;
910

Diff for: t/01base.t

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More qw/no_plan/;
89
use File::Spec;
910

@@ -40,10 +41,10 @@ ok defined($v), 'Fix for RT #47980';
4041
eval { version::new() };
4142
like $@, qr'Usage: version::new\(class, version\)',
4243
'No bus err when called as function';
43-
eval { $x = 1; print version::new };
44+
eval { my $x = 1; print version::new };
4445
like $@, qr'Usage: version::new\(class, version\)',
4546
'No implicit object creation when called as function';
46-
eval { $x = "version"; print version::new };
47+
eval { my $x = "version"; print version::new };
4748
like $@, qr'Usage: version::new\(class, version\)',
4849
'No implicit object creation when called as function';
4950
}

Diff for: t/02derived.t

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More qw/no_plan/;
89
use File::Spec;
910
use File::Temp qw/tempfile/;

Diff for: t/03require.t

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More qw/no_plan/;
89
use File::Spec;
910

Diff for: t/04strict_lax.t

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More qw/no_plan/;
89

910
# do strict lax tests in a sub to isolate a package to test importing
@@ -27,7 +28,7 @@ SKIP: {
2728
is ref($version::STRICT_DECIMAL_VERSION), 'Regexp', 'Can see $version::STRICT_DECIMAL_VERSION '.$version::STRICT_DECIMAL_VERSION;
2829
is ref($version::STRICT_DOTTED_DECIMAL_VERSION), 'Regexp', 'Can see $version::STRICT_DOTTED_DECIMAL_VERSION '.$version::STRICT_DOTTED_DECIMAL_VERSION;
2930
{ # https://rt.cpan.org/Ticket/Display.html?id=119669
30-
($v) = ( "snapshot-1.2.3ga-001-432" =~ /($version::LAX_DOTTED_DECIMAL_VERSION)/ );
31+
my ($v) = ( "snapshot-1.2.3ga-001-432" =~ /($version::LAX_DOTTED_DECIMAL_VERSION)/ );
3132
is $v, '1.2.3', "Extract just the version: $v";
3233
($v) = ( "snapshot-1.2ga-001-432" =~ /($version::LAX_DECIMAL_VERSION)/ );
3334
is $v, '1.2', "Extract just the version: $v";

Diff for: t/05sigdie.t

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More tests => 1;
89

910
BEGIN {

Diff for: t/06noop.t

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More qw/no_plan/;
89

910
BEGIN {

Diff for: t/07locale.t

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#########################
66

7+
use strict;
8+
79
use File::Basename;
810
use File::Temp qw/tempfile/;
911
use POSIX qw/locale_h/;
@@ -44,7 +46,7 @@ SKIP: {
4446
setlocale(LC_NUMERIC, $loc);
4547
$ver = 1.23; # has to be floating point number
4648
ok ($ver eq "1,23", "Using locale: $loc");
47-
$v = 'version'->new($ver);
49+
my $v = 'version'->new($ver);
4850
unlike($warning, qr/Version string '1,23' contains invalid data/,
4951
"Process locale-dependent floating point");
5052
ok ($v eq "1.23", "Locale doesn't apply to version objects");

Diff for: t/08_corelist.t

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#########################
66

7+
use strict;
78
use Test::More tests => 3;
89
use_ok("version", 0.9926);
910

Diff for: t/10_lyon.t

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! perl
22

3+
use strict;
34
use Test::More qw/no_plan/;
45

56
use version;

Diff for: t/11_taint.t

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!perl -T
2+
3+
use strict;
24
use Test::More;
35
use version;
46

Diff for: t/coretests.pm

+28-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#! /usr/local/perl -w
22
package main;
3+
4+
use strict;
35
require Test::Harness;
46
use Data::Dumper;
57
use File::Temp qw/tempfile/;
@@ -10,7 +12,10 @@ if ($Test::More::VERSION < 0.48) { # Fix for RT#48268
1012
*main::use_ok = sub ($;@) {
1113
my ($pkg, $req, @args) = @_;
1214
eval "use $pkg $req ".join(' ',@args);
13-
is ${"$pkg\::VERSION"}, eval($req), 'Had to manually use version';
15+
{
16+
no strict 'refs';
17+
is ${"$pkg\::VERSION"}, eval($req), 'Had to manually use version';
18+
}
1419
# If we made it this far, we are ok.
1520
};
1621
}
@@ -25,7 +30,7 @@ sub BaseTests {
2530
# its man page ( perldoc Test ) for help writing this test script.
2631

2732
# Test bare number processing
28-
$version = $CLASS->$method(5.005_03);
33+
my $version = $CLASS->$method(5.005_03);
2934
is ( "$version" , "5.00503" , '5.005_03 eq 5.00503' );
3035
$version = $CLASS->$method(1.23);
3136
is ( "$version" , "1.23" , '1.23 eq "1.23"' );
@@ -97,7 +102,7 @@ sub BaseTests {
97102
# Test Numeric Comparison operators
98103
# test first with non-object
99104
$version = $CLASS->$method("5.006.001");
100-
$new_version = "5.8.0";
105+
my $new_version = "5.8.0";
101106
ok ( $version == $version, '$version == $version' );
102107
ok ( $version < $new_version, '$version < $new_version' );
103108
ok ( $new_version > $version, '$new_version > $version' );
@@ -303,7 +308,7 @@ SKIP: {
303308
{ # dummy up some variously broken modules for testing
304309
my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
305310
(my $package = basename($filename)) =~ s/\.pm$//;
306-
print $fh "package $package;\n\@VERSION = ();\n1;\n";
311+
print $fh "package $package;\nour \@VERSION = ();\n1;\n";
307312
close $fh;
308313
eval "use lib '.'; use $package 3;";
309314
like ($@, qr/$error_regex/,
@@ -318,7 +323,7 @@ SKIP: { # https://rt.perl.org/rt3/Ticket/Display.html?id=95544
318323
unless defined $qv_declare;
319324
my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
320325
(my $package = basename($filename)) =~ s/\.pm$//;
321-
print $fh "package $package;\n\$VERSION = '3alpha';\n1;\n";
326+
print $fh "package $package;\nour \$VERSION = '3alpha';\n1;\n";
322327
close $fh;
323328
eval "use lib '.'; use $package; print $package->VERSION";
324329
like ($@, qr/Invalid version format \(non-numeric data\)/,
@@ -338,7 +343,8 @@ SKIP: {
338343
ok($version == $new_version, '$version == $new_version');
339344
skip "version require'd instead of use'd, cannot test declare", 1
340345
unless defined $qv_declare;
341-
$version = &$qv_declare(1.2.3);
346+
347+
$version = main->can($qv_declare)->(1.2.3);
342348
ok("$version" eq "v1.2.3", 'v-string initialized $qv_declare()');
343349
}
344350

@@ -400,7 +406,7 @@ SKIP: {
400406
(my $package = basename($filename)) =~ s/\.pm$//;
401407
print $fh <<"EOF";
402408
package $package;
403-
use $CLASS; \$VERSION = ${CLASS}->new('0.0.4');
409+
use $CLASS; our \$VERSION = ${CLASS}->new('0.0.4');
404410
1;
405411
EOF
406412
close $fh;
@@ -429,22 +435,26 @@ EOF
429435
}
430436

431437
SKIP: {
432-
skip "Cannot test \"use parent $CLASS\" when require is used", 3
438+
skip "Cannot test \"use base $CLASS\" when require is used", 3
433439
unless defined $qv_declare;
434440
my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
435441
(my $package = basename($filename)) =~ s/\.pm$//;
436442
print $fh <<"EOF";
437443
package $package;
438-
use base $CLASS;
444+
use base '$CLASS';
439445
1;
440446
EOF
441447
close $fh;
442448
# need to eliminate any other $qv_declare()'s
443-
undef *{"main\::$qv_declare"};
444-
ok(!defined(&{"main\::$qv_declare"}), "make sure we cleared $qv_declare() properly");
449+
{
450+
no strict 'refs';
451+
undef *{"main\::$qv_declare"};
452+
}
453+
ok(!main->can($qv_declare), "make sure we cleared $qv_declare() properly");
445454
eval "use lib '.'; use $package qw/declare qv/;";
455+
die "Error from test: $@" if $@;
446456
ok(defined(&{"main\::$qv_declare"}), "make sure we exported $qv_declare() properly");
447-
isa_ok( &$qv_declare(1.2), $package);
457+
isa_ok( main->can($qv_declare)->(1.2), $package);
448458
unlink $filename;
449459
}
450460

@@ -456,7 +466,7 @@ SKIP: {
456466
(my $package = basename($filename)) =~ s/\.pm$//;
457467
print $fh <<"EOF";
458468
package $package;
459-
\$VERSION = 1.0;
469+
our \$VERSION = 1.0;
460470
1;
461471
EOF
462472
close $fh;
@@ -614,23 +624,23 @@ SKIP: {
614624
}
615625
{
616626
# now as a number
617-
$two31 = 2**31;
618-
$v = $CLASS->new($two31);
627+
my $two31 = 2**31;
628+
my $v = $CLASS->new($two31);
619629
is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX';
620630
like $warning, qr/Integer overflow in version/, 'Overflow warning';
621631
}
622632
{ # https://rt.cpan.org/Ticket/Display.html?id=101628
623633
undef $warning;
624-
$v = $CLASS->new('1.1.00000000010');
634+
my $v = $CLASS->new('1.1.00000000010');
625635
is $v->normal, "v1.1.10", 'Ignore leading zeros';
626636
unlike $warning, qr/Integer overflow in version/, 'No overflow warning';
627637
}
628638
{ # https://rt.cpan.org/Ticket/Display.html?id=93340
629-
$v = $CLASS->parse(q[2.6_01]);
639+
my $v = $CLASS->parse(q[2.6_01]);
630640
is $v->normal, 'v2.601.0', 'Normal strips underscores from alphas'
631641
}
632642
{ # https://rt.cpan.org/Ticket/Display.html?id=98744
633-
$v = $CLASS->new("1.02_003");
643+
my $v = $CLASS->new("1.02_003");
634644
is $v->numify, '1.020030', 'Ignore underscores for numify';
635645
}
636646
}

0 commit comments

Comments
 (0)