File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -569,9 +569,28 @@ sub parse_version {
569569sub normalize_version {
570570 my($self ,$v ) = @_ ;
571571 $v = "undef" unless defined $v ;
572+
573+ # What on earth is this hunk about? Well, if the user has written
574+ #
575+ # $VERSION = 0.000001
576+ #
577+ # ...instead of...
578+ #
579+ # $VERSION = '0.000001'
580+ #
581+ # ...then when we eval the version value, we get a number. That's bad,
582+ # because we'll lose fidelity. Sometimes this only means that 1.100
583+ # becomes 1.1, but the worse case is when a version like 0.000001 becomes
584+ # 1e-6, which then can't be turned into a version object with version->new.
585+ #
586+ # If the stringified version appears to be scientific notation, format it
587+ # back into expanded form and make a version of that.
572588 my $dv = Dumpvalue->new;
573- my $sdv = $dv ->stringify($v ,1); # second argument prevents ticks
574- $Logger ->log("result of normalize_version: $sdv ");
589+ my $sdv = $dv ->stringify($v , 1); # second argument prevents ticks
590+ if ($sdv =~ /\A [0-9](?:\. [0-9]+)?e([-+])?[0-9]+\z /a) {
591+ my $adj = $1 eq '-' ? 'small' : 'large';
592+ die "very large or small numeric version; you must use a string in your source\n ";
593+ }
575594
576595 return $v if $v eq "undef";
577596 return $v if $v =~ /^\{ .*\} $/ ; # JSON object
Original file line number Diff line number Diff line change @@ -581,6 +581,29 @@ subtest "do not index dists without META file" => sub {
581581 );
582582};
583583
584+ subtest " very small version number (as numeric literal)" => sub {
585+ my $pause = PAUSE::TestPAUSE-> init_new;
586+ $pause -> upload_author_fake(PERSON => ' Tiny-Version-1.002.tar.gz' , {
587+ packages => [
588+ ' Tiny::Version' => {
589+ version => ' 0.000001' ,
590+ layout => { version => ' our-literal' },
591+ },
592+ ],
593+ });
594+
595+ my $result = $pause -> test_reindex;
596+
597+ $pause -> file_not_updated_ok(
598+ $result -> tmpdir
599+ -> file(qw( cpan modules 02packages.details.txt.gz) ),
600+ " there were no things to update" ,
601+ );
602+
603+ local $TODO = " sending a useful warning here is more or less impossible" ;
604+ fail(" assert a report was sent with an explanation" );
605+ };
606+
584607done_testing;
585608
586609# Local Variables:
You can’t perform that action at this time.
0 commit comments