Skip to content

Commit 0dc7a73

Browse files
committed
fix use tests: all versions up to 41.7 are valid
use-ing these versions will load the :5.41 bundle, since that's the highest one before them. This also means that we don't need to give hints about why 'use 5.6' or 'use 5.10' fail, because they won't anymore.
1 parent a7971fb commit 0dc7a73

File tree

2 files changed

+23
-44
lines changed

2 files changed

+23
-44
lines changed

pp_ctl.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4417,37 +4417,11 @@ S_require_version(pTHX_ SV *sv)
44174417
/* get the left hand term */
44184418
lav = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(req), "version", FALSE));
44194419

4420-
first = SvIV(*av_fetch(lav,0,0));
4421-
if ( first > (int)PERL_REVISION /* probably 'use 6.0' */
4422-
|| hv_exists(MUTABLE_HV(req), "qv", 2 ) /* qv style */
4423-
|| av_count(lav) > 2 /* FP with > 3 digits */
4424-
|| strstr(SvPVX(pv),".0") /* FP with leading 0 */
4425-
) {
4426-
DIE(aTHX_ "Perl %" SVf " required--this is only "
4427-
"%" SVf ", stopped",
4428-
SVfARG(sv_2mortal(vnormal(req))),
4429-
SVfARG(sv_2mortal(vnormal(PL_patchlevel)))
4430-
);
4431-
}
4432-
else { /* probably 'use 5.10' or 'use 5.8' */
4433-
SV *hintsv;
4434-
I32 second = 0;
4435-
4436-
if (av_count(lav) > 1)
4437-
second = SvIV(*av_fetch(lav,1,0));
4438-
4439-
second /= second >= 600 ? 100 : 10;
4440-
hintsv = Perl_newSVpvf(aTHX_ "v%d.%d.0",
4441-
(int)first, (int)second);
4442-
upg_version(hintsv, TRUE);
4443-
4444-
DIE(aTHX_ "Perl %" SVf " required (did you mean %" SVf "?)"
4445-
"--this is only %" SVf ", stopped",
4446-
SVfARG(sv_2mortal(vnormal(req))),
4447-
SVfARG(sv_2mortal(vnormal(sv_2mortal(hintsv)))),
4448-
SVfARG(sv_2mortal(vnormal(PL_patchlevel)))
4449-
);
4450-
}
4420+
DIE(aTHX_ "Perl %" SVf " required--this is only "
4421+
"%" SVf ", stopped",
4422+
SVfARG(sv_2mortal(vnormal(req))),
4423+
SVfARG(sv_2mortal(vnormal(PL_patchlevel)))
4424+
);
44514425
}
44524426
}
44534427

t/comp/use.t

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
$INC{"feature.pm"} = 1; # so we don't attempt to load feature.pm
77
}
88

9-
print "1..87\n";
9+
print "1..88\n";
1010

1111
# Can't require test.pl, as we're testing the use/require mechanism here.
1212

@@ -87,7 +87,7 @@ eval q{ use v5.5.630; };
8787
is ($@, '');
8888

8989
eval q{ use 10.0.2; };
90-
like ($@, qr/^\QPerl v10.0.2 required\E/);
90+
is ($@, '');
9191

9292
eval "use 5.000"; # implicit semicolon
9393
is ($@, '');
@@ -96,41 +96,46 @@ eval "use 5.000;";
9696
is ($@, '');
9797

9898
eval "use 6.000;";
99-
like ($@, qr/\QPerl v6.0.0 required--this is only $^V, stopped\E/);
99+
is ($@, '');
100100

101101
eval "no 6.000;";
102-
is ($@, '');
102+
like ($@, qr/\QPerls since v6.0.0 too modern--this is $^V, stopped\E/);
103103

104104
eval "no 5.000;";
105105
like ($@, qr/\QPerls since v5.0.0 too modern--this is $^V, stopped\E/);
106106

107107
eval "use 5.6;";
108-
like ($@, qr/\QPerl v5.600.0 required (did you mean v5.6.0?)--this is only $^V, stopped\E/);
108+
is ($@, '');
109109

110110
eval "use 5.8;";
111-
like ($@, qr/\QPerl v5.800.0 required (did you mean v5.8.0?)--this is only $^V, stopped\E/);
111+
is ($@, '');
112112

113113
eval "use 5.9;";
114-
like ($@, qr/\QPerl v5.900.0 required (did you mean v5.9.0?)--this is only $^V, stopped\E/);
114+
is ($@, '');
115115

116116
eval "use 5.10;";
117-
like ($@, qr/\QPerl v5.100.0 required (did you mean v5.10.0?)--this is only $^V, stopped\E/);
117+
is ($@, '');
118118

119119
eval "use 5.11;";
120-
like ($@, qr/\QPerl v5.110.0 required (did you mean v5.11.0?)--this is only $^V, stopped\E/);
120+
is ($@, '');
121121

122122
eval sprintf "use %.6f;", $];
123123
is ($@, '');
124124

125125

126-
eval sprintf "use %.6f;", $] - 0.000001;
126+
eval sprintf "use %.6f;", $] - 0.001;
127127
is ($@, '');
128128

129+
my $Vthis = int $];
130+
my $Vnext = $Vthis + 1;
129131
eval sprintf("use %.6f;", $] + 1);
130-
like ($@, qr/Perl v6\.\d+\.\d+ required--this is only \Q$^V\E, stopped/a);
132+
like ($@, qr/Perl v$Vnext\.\d+\.\d+ required--this is only \Q$^V\E, stopped/a);
133+
134+
eval sprintf "use %.6f;", $] + 0.001;
135+
like ($@, qr/Perl v$Vthis\.\d+\.\d+ required--this is only \Q$^V\E, stopped/a);
131136

132-
eval sprintf "use %.6f;", $] + 0.00001;
133-
like ($@, qr/Perl v5\.\d+\.\d+ required--this is only \Q$^V\E, stopped/a);
137+
eval sprintf "use %.3f;", $Vthis + .999;
138+
like ($@, qr/Perl v$Vthis\.\d+\.\d+ required--this is only \Q$^V\E, stopped/a);
134139

135140
# check that "use 5.11.0" (and higher) loads strictures
136141
eval 'use 5.11.0; ${"foo"} = "bar";';

0 commit comments

Comments
 (0)