forked from andk/cpanpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10version.t
129 lines (122 loc) · 2.63 KB
/
10version.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- Mode: cperl; coding: utf-8; -*-
use strict;
use CPAN::Version;
use vars qw($D $N);
# for debugging uncomment the next two lines
# use CPAN;
# $CPAN::DEBUG = 16384;
while (<DATA>) {
next if tr/.// > 1 && $]<5.006; # multidot tests are not for pre-5.6.0
last if /^__END__$/;
chomp;
s/\s*#.*//;
push @$D, [ split ];
}
$N = scalar @$D;
print "1..$N\n";
my $has_sort_versions = eval { require Sort::Versions; 1 };
my $has_versionpm = eval q{ use version 0.7203; 1 };
my $has_perl_versionpm = eval { require Perl::Version; 1 };
while (@$D) {
my($l,$r,$exp) = @{shift @$D};
my $res = CPAN::Version->vcmp($l,$r);
if ($res != $exp){
print "# l[$l]r[$r]exp[$exp]res[$res]\n";
print "not ";
}
my @other = ();
if ($has_sort_versions) {
if (Sort::Versions::versioncmp($l,$r) != $res) {
push @other, sprintf "SV: %d", Sort::Versions::versioncmp($l,$r);
}
}
if ($has_versionpm) {
local $^W;
my $vpack = "version"; # hide the name from 5.004
my $vres = eval { $vpack->new($l) cmp $vpack->new($r); };
if ($@) {
push @other, "v.pm: $@";
} elsif ($vres != $res) {
push @other, sprintf "v.pm: %d", $vres;
}
}
if ($has_perl_versionpm) {
local $^W;
my $vpack = "Perl::Version"; # hide the name from 5.004
my $vres = eval { $vpack->new($l) cmp $vpack->new($r); };
if ($@) {
push @other, "PV: $@";
} elsif ($vres != $res) {
push @other, sprintf "PV: %d", $vres;
}
}
my $other = @other ? " (".join("; ", @other).")" : "";
printf "ok %2d # %12s %12s %3d%s\n", $N-@$D, $l, $r, $res, $other;
die "Panic" if CPAN::Version->vgt($l,$r) && CPAN::Version->vlt($l,$r);
}
__END__
0 0 0
1 0 1
0 1 -1
1 1 0
1.1 0.0a 1
1.1a 0.0 1
1.2.3 1.1.1 1
v1.2.3 v1.1.1 1
v1.2.3 v1.2.1 1
v1.2.3 v1.2.11 -1
v2.4 2.004000 -1
v2.4 2.004 0
1.2.3 1.2.11 -1
1.9 1.10 1
VERSION VERSION 0
0.02 undef 1
1.57_00 1.57 1
1.5700 1.57 1
1.57_01 1.57 1
1.88_51 1.8801 1
1.8_8_5_1 1.8801 1
0.2.10 0.2 -1
20000000.00 19990108 1
1.00 0.96 1
0.7.2 0.7 -1
0.7.02 0.7 -1
0.07.02 0.7 -1
1.3a5 1.3 1
undef 1.00 -1
v1.0 undef 1
v0.2.4 0.24 -1
v1.0.22 122 -1
1.0.22 122 -1
5.00556 v5.5.560 0
5.005056 v5.5.56 0
5.00557 v5.5.560 1
5.00056 v5.0.561 -1
0.0.2 0.000002 0
1.0.3 1.000003 0
1.0.1 1.000001 0
0.0.1 0.000001 0
0.01.04 0.001004 0
0.05.18 0.005018 0
4.08.00 4.008000 0
0.001.004 0.001004 0
0.005.018 0.005018 0
4.008.000 4.008000 0
4.008.000 4.008 1
v4.8 4.008 0
v4.8.0 4.008000 0
v1.99.1_1 1.98 -1
v2.3999 v2.4000 -1
v2.3999 2.004000 1
v2.3999 2.999999 1
v2.1000 2.999999 1
0123 123 -1
v2.005 2.005 0
v1.0 1.0 0
v1.0 1.000 0
v1.0 1.000000 0
__END__
# Local Variables:
# mode: cperl
# cperl-indent-level: 2
# End: