Reword the copyright notices to match what's suggested in GPLv3.
[automake/plouj.git] / lib / Automake / tests / Version.pl
blobeaf2767a9931a9c4bc0dc492cf820aa9d58053ce
1 # Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3 # This file is part of GNU Automake.
5 # GNU Automake is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3, or (at your option)
8 # any later version.
10 # GNU Automake is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 use Automake::Version;
20 my $failed = 0;
22 sub test_version_compare
24 my ($left, $right, $result) = @_;
25 my @leftver = Automake::Version::split ($left);
26 my @rightver = Automake::Version::split ($right);
27 if ($#leftver == -1)
29 print "can't grok \"$left\"\n";
30 $failed = 1;
31 return;
33 if ($#rightver == -1)
35 print "can't grok \"$right\"\n";
36 $failed = 1;
37 return;
39 my $res = Automake::Version::compare (@leftver, @rightver);
40 if ($res != $result)
42 print "compare (\"$left\", \"$right\") = $res! (not $result?)\n";
43 $failed = 1;
47 my @tests = (
48 # basics
49 ['1.0', '2.0', -1],
50 ['2.0', '1.0', 1],
51 ['1.2', '1.2', 0],
52 ['1.1', '1.2', -1],
53 ['1.2', '1.1', 1],
54 # alphas
55 ['1.4', '1.4g', -1],
56 ['1.4g', '1.5', -1],
57 ['1.4g', '1.4', 1],
58 ['1.5', '1.4g', 1],
59 ['1.4a', '1.4g', -1],
60 ['1.5a', '1.3g', 1],
61 ['1.6a', '1.6a', 0],
62 # micros
63 ['1.5.1', '1.5', 1],
64 ['1.5.0', '1.5', 0],
65 ['1.5.4', '1.6.1', -1],
66 # micros and alphas
67 ['1.5a', '1.5.1', 1],
68 ['1.5a', '1.5.1a', 1],
69 ['1.5a', '1.5.1f', 1],
70 ['1.5', '1.5.1a', -1],
71 ['1.5.1a', '1.5.1f', -1],
72 # special exceptions
73 ['1.6-p5a', '1.6.5a', 0],
74 ['1.6', '1.6-p5a', -1],
75 ['1.6-p4b', '1.6-p5a', -1],
76 ['1.6-p4b', '1.6-foo', 1],
77 ['1.6-p4b', '1.6a-foo', -1]
80 test_version_compare (@{$_}) foreach @tests;
82 exit $failed;
84 ### Setup "GNU" style for perl-mode and cperl-mode.
85 ## Local Variables:
86 ## perl-indent-level: 2
87 ## perl-continued-statement-offset: 2
88 ## perl-continued-brace-offset: 0
89 ## perl-brace-offset: 0
90 ## perl-brace-imaginary-offset: 0
91 ## perl-label-offset: -2
92 ## cperl-indent-level: 2
93 ## cperl-brace-offset: 0
94 ## cperl-continued-brace-offset: 0
95 ## cperl-label-offset: -2
96 ## cperl-extra-newline-before-brace: t
97 ## cperl-merge-trailing-else: nil
98 ## cperl-continued-statement-offset: 2
99 ## End: