Skip to content

Commit 5e6079a

Browse files
bookericherman
authored andcommitted
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 fe4a119 commit 5e6079a

File tree

2 files changed

+23
-51
lines changed

2 files changed

+23
-51
lines changed

pp_ctl.c

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,45 +4478,12 @@ S_require_version(pTHX_ SV *sv)
44784478
}
44794479
else {
44804480
if ( vcmp(sv,PL_patchlevel) > 0 ) {
4481-
I32 first = 0;
4482-
AV *lav;
44834481
SV * const req = SvRV(sv);
4484-
SV * const pv = *hv_fetchs(MUTABLE_HV(req), "original", FALSE);
4485-
4486-
/* get the left hand term */
4487-
lav = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(req), "version", FALSE));
4488-
4489-
first = SvIV(*av_fetch(lav,0,0));
4490-
if ( first > (int)PERL_REVISION /* probably 'use 6.0' */
4491-
|| hv_exists(MUTABLE_HV(req), "qv", 2 ) /* qv style */
4492-
|| av_count(lav) > 2 /* FP with > 3 digits */
4493-
|| strstr(SvPVX(pv),".0") /* FP with leading 0 */
4494-
) {
4495-
DIE(aTHX_ "Perl %" SVf " required--this is only "
4496-
"%" SVf ", stopped",
4497-
SVfARG(sv_2mortal(vnormal(req))),
4498-
SVfARG(sv_2mortal(vnormal(PL_patchlevel)))
4499-
);
4500-
}
4501-
else { /* probably 'use 5.10' or 'use 5.8' */
4502-
SV *hintsv;
4503-
I32 second = 0;
4504-
4505-
if (av_count(lav) > 1)
4506-
second = SvIV(*av_fetch(lav,1,0));
4507-
4508-
second /= second >= 600 ? 100 : 10;
4509-
hintsv = Perl_newSVpvf(aTHX_ "v%d.%d.0",
4510-
(int)first, (int)second);
4511-
upg_version(hintsv, TRUE);
4512-
4513-
DIE(aTHX_ "Perl %" SVf " required (did you mean %" SVf "?)"
4514-
"--this is only %" SVf ", stopped",
4515-
SVfARG(sv_2mortal(vnormal(req))),
4516-
SVfARG(sv_2mortal(vnormal(sv_2mortal(hintsv)))),
4517-
SVfARG(sv_2mortal(vnormal(PL_patchlevel)))
4518-
);
4519-
}
4482+
DIE(aTHX_ "Perl %" SVf " required--this is only "
4483+
"%" SVf ", stopped",
4484+
SVfARG(sv_2mortal(vnormal(req))),
4485+
SVfARG(sv_2mortal(vnormal(PL_patchlevel)))
4486+
);
45204487
}
45214488
}
45224489

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)