Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 118493
Status: open
Priority: 0/
Queue: version

People
Owner: Nobody in particular
Requestors: info [...] maximka.de
Cc:
AdminCc:

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



Subject: How to compare version objects
there is an example in version.pod: $v1 = version->parse("v0.95.0"); $bool = $v1 < 0.96; # FALSE since 0.96 is v0.960.0 But my test returned true. ---- my $v1 = version->parse("v0.95.0"); my $v2 = 0.96; say join ' ', $v1, ($v1 < $v2) ? '<' : '>', $v2; say join ' ', $v1, ($v1 < version->parse($v2)) ? '<' : '>', version->parse($v2); say join ' ', $v1, ($v1 < version->parse("v$v2")) ? '<' : '>', version->parse("v$v2"); ---- v0.95.0 < 0.96 v0.95.0 < 0.96 v0.95.0 < v0.96 ---- From my understanding only the last comparison should return true.
On 2016-10-24 13:09:55, palik wrote: Show quoted text
> there is an example in version.pod:
The pod examples are wrong and should be fixed. I would suggest writing unit tests against them all as well, to ensure they stay correct.
On Tue Oct 25 17:10:49 2016, ETHER wrote: Show quoted text
> On 2016-10-24 13:09:55, palik wrote:
> > there is an example in version.pod:
> > The pod examples are wrong and should be fixed. > > I would suggest writing unit tests against them all as well, to ensure > they stay correct.
I haven't had much time to dedicate to version.pm work, but I will get to this. I looked at the modules on CPAN that support testing POD examples and they have fairly steep dependency trees, so that isn't really suitable for any that ships with Core Perl. I will probably write an author-only test file or something. John
Documentation looks massively outdated. E. g.: Show quoted text
> Important Note: Even if you pass in what looks like a decimal number ("1.2"), a dotted-decimal will be created ("v1.200.0").
It is about 'declare'. Current version (0.9917) creates v1.2.0, NOT v1.200.0. Show quoted text
> Note that "alpha" version objects (where the version string contains a trailing underscore segment) compare as less than the equivalent version without an underscore:
Show quoted text
> $bool = version->parse("1.23_45") < version->parse("1.2345"); # TRUE
In current version implementation 1.23_45 == 1.2345. And so on.
PRs are now possible on https://github.com/JohnPeacock/version.pm and my one for metadata was merged and released within hours! For auto-testing all POD code examples, here is some code from Inline::Java that does this quite nicely: https://github.com/ingydotnet/Inline-Java/blob/master/xt/pod_test.t
I'm not sure it's outdated. For example, version->parse("1.23_45") < version->parse("1.2345") is false, but Perl::Version->new("1.23_45") < Perl::Version->new("1.2345") is true. So I'd say the documentation is correct, but the implementation is wrong. On Tue Dec 27 16:27:36 2016, VDB wrote: Show quoted text
> Documentation looks massively outdated. E. g.: >
> > Important Note: Even if you pass in what looks like a decimal number > > ("1.2"), a dotted-decimal will be created ("v1.200.0").
> > It is about 'declare'. Current version (0.9917) creates v1.2.0, NOT > v1.200.0. >
> > Note that "alpha" version objects (where the version string contains > > a trailing underscore segment) compare as less than the equivalent > > version without an underscore:
>
> > $bool = version->parse("1.23_45") < version->parse("1.2345"); # TRUE
> > In current version implementation 1.23_45 == 1.2345. > > And so on.
On Tue Apr 28 18:44:14 2020, CHOROBA wrote: Show quoted text
> I'm not sure it's outdated. For example, > > version->parse("1.23_45") < version->parse("1.2345") > > is false, but > > Perl::Version->new("1.23_45") < Perl::Version->new("1.2345") > > is true. So I'd say the documentation is correct, but the > implementation is wrong. > > On Tue Dec 27 16:27:36 2016, VDB wrote:
> > Documentation looks massively outdated. E. g.: > >
> > > Important Note: Even if you pass in what looks like a decimal > > > number > > > ("1.2"), a dotted-decimal will be created ("v1.200.0").
> > > > It is about 'declare'. Current version (0.9917) creates v1.2.0, NOT > > v1.200.0. > >
> > > Note that "alpha" version objects (where the version string > > > contains > > > a trailing underscore segment) compare as less than the equivalent > > > version without an underscore:
> >
> > > $bool = version->parse("1.23_45") < version->parse("1.2345"); # > > > TRUE
> > > > In current version implementation 1.23_45 == 1.2345. > > > > And so on.
Perl::Version is wrong here.