Upgrade to CPAN-1.88_52
[p5sagit/p5-mst-13.2.git] / lib / CPAN / t / 10version.t
CommitLineData
2787609a 1# -*- Mode: cperl; coding: utf-8; -*-
2
2787609a 3use strict;
554a9ef5 4use CPAN::Version;
2787609a 5use vars qw($D $N);
6
7while (<DATA>) {
0a78cd5d 8 next if tr/.// > 1 && $]<5.006; # multidot tests are not for pre-5.6.0
554a9ef5 9 last if /^__END__$/;
2787609a 10 chomp;
11 s/\s*#.*//;
12 push @$D, [ split ];
13}
14
15$N = scalar @$D;
16print "1..$N\n";
17
c9869e1c 18my $has_sort_versions = eval { require Sort::Versions; 1 };
19my $has_versionpm = eval { require version; 1 };
2787609a 20while (@$D) {
21 my($l,$r,$exp) = @{shift @$D};
22 my $res = CPAN::Version->vcmp($l,$r);
23 if ($res != $exp){
24 print "# l[$l]r[$r]exp[$exp]res[$res]\n";
25 print "not ";
26 }
c9869e1c 27 my @other = ();
28 if ($has_sort_versions) {
29 if (Sort::Versions::versioncmp($l,$r) != $res) {
30 push @other, sprintf "SV: %d", Sort::Versions::versioncmp($l,$r);
31 }
32 }
33 if ($has_versionpm) {
34 local $^W;
4d1321a7 35 my $vpack = "version"; # hide the name from 5.004
7d97ad34 36 my $vres = eval { $vpack->new($l) cmp $vpack->new($r); };
37 if ($@) {
38 push @other, "v.pm: $@";
39 } elsif ($vres != $res) {
c9869e1c 40 push @other, sprintf "v.pm: %d", $vres;
41 }
42 }
43 my $other = @other ? " (".join("; ", @other).")" : "";
44 printf "ok %2d # %12s %12s %3d%s\n", $N-@$D, $l, $r, $res, $other;
4d1321a7 45 die "Panic" if CPAN::Version->vgt($l,$r) && CPAN::Version->vlt($l,$r);
2787609a 46}
47
48__END__
490 0 0
501 0 1
510 1 -1
521 1 0
531.1 0.0a 1
541.1a 0.0 1
551.2.3 1.1.1 1
56v1.2.3 v1.1.1 1
57v1.2.3 v1.2.1 1
58v1.2.3 v1.2.11 -1
554a9ef5 591.2.3 1.2.11 -1
2787609a 601.9 1.10 1
61VERSION VERSION 0
620.02 undef 1
631.57_00 1.57 1
641.5700 1.57 1
651.57_01 1.57 1
7d97ad34 661.88_51 1.8801 1
671.8_8_5_1 1.8801 1
554a9ef5 680.2.10 0.2 -1
2787609a 6920000000.00 19990108 1
701.00 0.96 1
c9869e1c 710.7.2 0.7 -1
554a9ef5 720.7.02 0.7 -1
c9869e1c 730.07.02 0.7 -1
2787609a 741.3a5 1.3 1
75undef 1.00 -1
76v1.0 undef 1
77v0.2.4 0.24 -1
78v1.0.22 122 -1
c9869e1c 791.0.22 122 -1
2787609a 805.00556 v5.5.560 0
815.005056 v5.5.56 0
825.00557 v5.5.560 1
835.00056 v5.0.561 -1
554a9ef5 840.0.2 0.000002 0
851.0.3 1.000003 0
861.0.1 1.000001 0
870.0.1 0.000001 0
880.01.04 0.001004 0
890.05.18 0.005018 0
904.08.00 4.008000 0
c9869e1c 910.001.004 0.001004 0
920.005.018 0.005018 0
934.008.000 4.008000 0
944.008.000 4.008 1
554a9ef5 95__END__
96
97# Local Variables:
98# mode: cperl
99# cperl-indent-level: 2
100# End: