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