Upgrade to CPAN-1.83_66.
[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
810a0276 7# for debugging uncomment the next two lines
8# use CPAN;
9# $CPAN::DEBUG = 16384;
10
2787609a 11while (<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;
20print "1..$N\n";
21
c9869e1c 22my $has_sort_versions = eval { require Sort::Versions; 1 };
23my $has_versionpm = eval { require version; 1 };
2787609a 24while (@$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 }
c9869e1c 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;
4d1321a7 39 my $vpack = "version"; # hide the name from 5.004
7d97ad34 40 my $vres = eval { $vpack->new($l) cmp $vpack->new($r); };
41 if ($@) {
42 push @other, "v.pm: $@";
43 } elsif ($vres != $res) {
c9869e1c 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;
4d1321a7 49 die "Panic" if CPAN::Version->vgt($l,$r) && CPAN::Version->vlt($l,$r);
2787609a 50}
51
52__END__
530 0 0
541 0 1
550 1 -1
561 1 0
571.1 0.0a 1
581.1a 0.0 1
591.2.3 1.1.1 1
60v1.2.3 v1.1.1 1
61v1.2.3 v1.2.1 1
62v1.2.3 v1.2.11 -1
554a9ef5 631.2.3 1.2.11 -1
2787609a 641.9 1.10 1
65VERSION VERSION 0
660.02 undef 1
671.57_00 1.57 1
681.5700 1.57 1
691.57_01 1.57 1
7d97ad34 701.88_51 1.8801 1
711.8_8_5_1 1.8801 1
554a9ef5 720.2.10 0.2 -1
2787609a 7320000000.00 19990108 1
741.00 0.96 1
c9869e1c 750.7.2 0.7 -1
554a9ef5 760.7.02 0.7 -1
c9869e1c 770.07.02 0.7 -1
2787609a 781.3a5 1.3 1
79undef 1.00 -1
80v1.0 undef 1
81v0.2.4 0.24 -1
82v1.0.22 122 -1
c9869e1c 831.0.22 122 -1
2787609a 845.00556 v5.5.560 0
855.005056 v5.5.56 0
865.00557 v5.5.560 1
875.00056 v5.0.561 -1
554a9ef5 880.0.2 0.000002 0
891.0.3 1.000003 0
901.0.1 1.000001 0
910.0.1 0.000001 0
920.01.04 0.001004 0
930.05.18 0.005018 0
944.08.00 4.008000 0
c9869e1c 950.001.004 0.001004 0
960.005.018 0.005018 0
974.008.000 4.008000 0
984.008.000 4.008 1
810a0276 99v1.99.1_1 1.98 -1
554a9ef5 100__END__
101
102# Local Variables:
103# mode: cperl
104# cperl-indent-level: 2
105# End: