Subject: | 1.2.1 is not > 1.2_1 |
use strict;
use warnings;
use Perl::Version;
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);
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-2.pl line 50.
# got: '-1'
# expected: '1'
ok 5