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