Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 64635
Status: resolved
Priority: 0/
Queue: version

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.88
Fixed in: (no value)



Subject: trailing zero behaviour of "numify" conflicts in various places.

Some places seem to indicate numify will return a trailing-zero free result. But in practice, it returns with the number of zeros being a multiple of 3.

We're wanting the trailing-zero's, but are wary of relying on a feature that works, but is contrary to documented behaviour, as things that are contrary to documented behaviour are deemed "bugs".


http://search.cpan.org/dist/version/lib/version.pod#numify%28%29 

numify()   Returns a value representing the object in a pure decimal form without trailing zeroes.

version->parse('1.2')->numify; # 1.2

http://search.cpan.org/~jpeacock/version-0.88/lib/version/Internals.pod

Numification:

For formatting purposes, when displaying a number which corresponds a version object, all sub versions are assumed to have three decimal places

http://cpansearch.perl.org/src/JPEACOCK/version-0.88/t/coretests.pm
 

    # trailing zero testing (reported by Andreas Koenig).
    $version = $CLASS->$method("1");
    ok($version->numify eq "1.000", "trailing zeros preserved");
    $version = $CLASS->$method("1.0");
    ok($version->numify eq "1.000", "trailing zeros preserved");
    $version = $CLASS->$method("1.0.0");
    ok($version->numify eq "1.000000", "trailing zeros preserved");
    $version = $CLASS->$method("1.0.0.0");
    ok($version->numify eq "1.000000000", "trailing zeros preserved");
    
    # leading zero testing (reported by Andreas Koenig).
    $version = $CLASS->$method(".7");
    ok($version->numify eq "0.700", "leading zero inferred");

    # leading space testing (reported by Andreas Koenig).
    $version = $CLASS->$method(" 1.7");
    ok($version->numify eq "1.700", "leading space ignored");



 

The documentation is in error. The "numify" operator has returned trailing zeros (in multiples of 3) since March 2006 and the POD never got updated. I'll take care of that momentarily (though I probably won't bother to release to CPAN until I get some more substantial changes). In general, however, you should not be using numify() or normal() directly to force a given representation. Version objects are guaranteed to compare either numerically or stringwise identically (since the non-object is parsed through the overloaded comparison operation). If you are using Version objects in some other code where you have to control the string output, it is probably better to create your own subclass to directly print out the internal version array to your own specifications.
From: paul [...] city-fan.org
On Sun Jan 09 20:28:10 2011, JPEACOCK wrote: Show quoted text
> The documentation is in error. The "numify" operator has returned > trailing zeros (in multiples of 3) since March 2006 and the POD never > got updated. I'll take care of that momentarily (though I probably > won't bother to release to CPAN until I get some more substantial changes).
Just noting that the documentation is still in error...
From: ppisar [...] redhat.com
Dne Ne 09.led.2011 15:14:37, KENTNL napsal(a): Show quoted text
> Some places seem to indicate numify will return a trailing-zero free > result. > But in practice, it returns with the number of zeros being a multiple > of 3.
I attached a documentation fix to similar CPAN RT#122858.