source: trunk/essentials/sys-devel/automake-1.7/tests/version5.test

Last change on this file was 3120, checked in by bird, 18 years ago

automake 1.7.9

File size: 2.4 KB
Line 
1#! /bin/sh
2# Copyright (C) 2002 Free Software Foundation, Inc.
3#
4# This file is part of GNU Automake.
5#
6# GNU Automake is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# GNU Automake is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with autoconf; see the file COPYING. If not, write to
18# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA.
20
21# Exercise &version_compare.
22
23. ./defs || exit 1
24
25set -e
26
27# FIXME: probably ought to let users override this like we do in `defs'.
28amfile=../../automake
29
30sed 1q $amfile >>automake_tmp
31cat << 'END' >> automake_tmp
32
33my $failed = 0;
34
35sub test_version_compare
36{
37 my ($left, $right, $result) = @_;
38 my @leftver = Automake::version_split ($left);
39 my @rightver = Automake::version_split ($right);
40 if ($#leftver == -1)
41 {
42 print "can't grok \"$left\"\n";
43 $failed = 1;
44 return;
45 }
46 if ($#rightver == -1)
47 {
48 print "can't grok \"$right\"\n";
49 $failed = 1;
50 return;
51 }
52 my $res = Automake::version_compare (\@leftver, \@rightver);
53 if ($res != $result)
54 {
55 print "version_compare (\"$left\", \"$right\") = $res! (not $result?)\n";
56 $failed = 1;
57 }
58}
59
60my @tests = (
61# basics
62 ['1.0', '2.0', -1],
63 ['2.0', '1.0', 1],
64 ['1.2', '1.2', 0],
65 ['1.1', '1.2', -1],
66 ['1.2', '1.1', 1],
67# alphas
68 ['1.4', '1.4g', -1],
69 ['1.4g', '1.5', -1],
70 ['1.4g', '1.4', 1],
71 ['1.5', '1.4g', 1],
72 ['1.4a', '1.4g', -1],
73 ['1.5a', '1.3g', 1],
74 ['1.6a', '1.6a', 0],
75# micros
76 ['1.5.1', '1.5', 1],
77 ['1.5.0', '1.5', 0],
78 ['1.5.4', '1.6.1', -1],
79# micros and alphas
80 ['1.5a', '1.5.1', 1],
81 ['1.5a', '1.5.1a', 1],
82 ['1.5a', '1.5.1f', 1],
83 ['1.5', '1.5.1a', -1],
84 ['1.5.1a', '1.5.1f', -1],
85# special exceptions
86 ['1.6-p5a', '1.6.5a', 0],
87 ['1.6', '1.6-p5a', -1],
88 ['1.6-p4b', '1.6-p5a', -1],
89 ['1.6-p4b', '1.6-foo', 1],
90 ['1.6-p4b', '1.6a-foo', -1]
91);
92
93test_version_compare (@{$_}) foreach @tests;
94
95exit $failed;
96END
97
98cat $amfile >>automake_tmp
99
100$PERL ./automake_tmp
Note: See TracBrowser for help on using the repository browser.