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