Fix missing @clicksequence problem with older Texinfo versions.
[pspp-builds.git] / tests / command / count.sh
1 #!/bin/sh
2
3 # This program tests the count transformation
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="Create File 1"
62 cat > $TESTFILE <<EOF
63 title 'Test COUNT transformation'.
64
65 * we're going to count the 2s 4s and 1s in the data
66 data list /V1 to V2 1-4(a).
67 begin data.
68 1234
69 321      <----
70 2 13     <----
71 4121
72 1104     ---- this is not '4', but '04' (v1 and v2 are string format )
73 03 4     <----
74 0193
75 end data.
76 count C=v1 to v2('2',' 4','1').
77 list.
78 EOF
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81
82 activity="Run pspp 1"
83 $SUPERVISOR $PSPP --testing-mode $TESTFILE
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86
87 activity="compare results 1"
88 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
89 diff -b  $TEMPDIR/pspp.list - <<EOF
90 1.1 DATA LIST.  Reading 1 record from INLINE.
91 +--------+------+-------+------+
92 |Variable|Record|Columns|Format|
93 #========#======#=======#======#
94 |V1      |     1|  1-  2|A2    |
95 |V2      |     1|  3-  4|A2    |
96 +--------+------+-------+------+
97 V1 V2        C
98 -- -- --------
99 12 34      .00 
100 32 1      1.00 
101 2  13     1.00 
102 41 21      .00 
103 11 04      .00 
104 03  4     1.00 
105 01 93      .00 
106 EOF
107 if [ $? -ne 0 ] ; then no_result ; fi
108
109
110
111
112 activity="Create file 2"
113 cat > $TESTFILE <<EOF
114 data list list /x * y *.
115 begin data.
116 1 2
117 2 3
118 4 5
119 2 2
120 5 6
121 end data.
122
123 count C=x y (2).
124
125 list.
126 EOF
127 if [ $? -ne 0 ] ; then no_result ; fi
128
129
130 activity="Run pspp 2"
131 $SUPERVISOR $PSPP --testing-mode $TESTFILE
132 if [ $? -ne 0 ] ; then no_result ; fi
133
134
135 activity="compare results"
136 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
137 diff -b  $TEMPDIR/pspp.list - <<EOF
138 1.1 DATA LIST.  Reading free-form data from INLINE.
139 +--------+------+
140 |Variable|Format|
141 #========#======#
142 |x       |F8.0  |
143 |y       |F8.0  |
144 +--------+------+
145        x        y        C
146 -------- -------- --------
147     1.00     2.00     1.00 
148     2.00     3.00     1.00 
149     4.00     5.00      .00 
150     2.00     2.00     2.00 
151     5.00     6.00      .00 
152 EOF
153 if [ $? -ne 0 ] ; then fail ; fi
154
155 pass;