Skip Menu |

This queue is for tickets about the version CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: lubos [...] kolouch.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.9924_02
Fixed in: (no value)



Subject: incorrect comparison of versions
sub compare_versions { my ($ver1, $ver2) = @_; my $v1 = version->new($ver1); my $v2 = version->new($ver2); return $v1 <=> $v2; } # TESTS use Test::More; is(compare_versions('0.1','1.1'),-1); is(compare_versions('2.0','1.2'),1); is(compare_versions('1.2','1.2_5'),-1); # There is likely bug in the module, I have reported it is(compare_versions('1.2.1','1.2_1'),1); is(compare_versions('1.2.1','1.2.1'),0); ok 1 ok 2 ok 3 not ok 4 # Failed test at ch-1.pl line 51. # got: '-1' # expected: '1' ok 5
On Sat May 02 10:44:53 2020, lubos@kolouch.net wrote: Show quoted text
> sub compare_versions { > my ($ver1, $ver2) = @_; > > my $v1 = version->new($ver1); > my $v2 = version->new($ver2); > > return $v1 <=> $v2; > } > > # TESTS > > use Test::More; > > is(compare_versions('0.1','1.1'),-1); > is(compare_versions('2.0','1.2'),1); > is(compare_versions('1.2','1.2_5'),-1); > > # There is likely bug in the module, I have reported it > is(compare_versions('1.2.1','1.2_1'),1); > is(compare_versions('1.2.1','1.2.1'),0); > > ok 1 > ok 2 > ok 3 > not ok 4 > # Failed test at ch-1.pl line 51. > # got: '-1' > # expected: '1' > ok 5
This seems to be a duplicate of https://rt.cpan.org/Ticket/Display.html?id=118493 which says the behaviour is correct, but the documentation (and Perl::Version) are wrong.
On Sun May 03 17:21:54 2020, CHOROBA wrote: Show quoted text
> On Sat May 02 10:44:53 2020, lubos@kolouch.net wrote:
> > sub compare_versions { > > my ($ver1, $ver2) = @_; > > > > my $v1 = version->new($ver1); > > my $v2 = version->new($ver2); > > > > return $v1 <=> $v2; > > } > > > > # TESTS > > > > use Test::More; > > > > is(compare_versions('0.1','1.1'),-1); > > is(compare_versions('2.0','1.2'),1); > > is(compare_versions('1.2','1.2_5'),-1); > > > > # There is likely bug in the module, I have reported it > > is(compare_versions('1.2.1','1.2_1'),1); > > is(compare_versions('1.2.1','1.2.1'),0); > > > > ok 1 > > ok 2 > > ok 3 > > not ok 4 > > # Failed test at ch-1.pl line 51. > > # got: '-1' > > # expected: '1' > > ok 5
> > This seems to be a duplicate of > > https://rt.cpan.org/Ticket/Display.html?id=118493 > > which says the behaviour is correct, but the documentation (and > Perl::Version) are wrong.
Explanation probably here: https://rt.cpan.org/Ticket/Display.html?id=119447
On Sat May 02 10:44:53 2020, lubos@kolouch.net wrote: Show quoted text
> sub compare_versions { > my ($ver1, $ver2) = @_; > > my $v1 = version->new($ver1); > my $v2 = version->new($ver2); > > return $v1 <=> $v2; > } > > # TESTS > > use Test::More; > > is(compare_versions('0.1','1.1'),-1); > is(compare_versions('2.0','1.2'),1); > is(compare_versions('1.2','1.2_5'),-1); > > # There is likely bug in the module, I have reported it > is(compare_versions('1.2.1','1.2_1'),1); > is(compare_versions('1.2.1','1.2.1'),0); > > ok 1 > ok 2 > ok 3 > not ok 4 > # Failed test at ch-1.pl line 51. > # got: '-1' > # expected: '1' > ok 5
1.2.1 is v1.2.1 1.2_1 is v1.21 v1.21 is greater than v1.2.1. The module's behavior is correct, and this test is wrong.