Fix missing @clicksequence problem with older Texinfo versions.
[pspp-builds.git] / tests / command / loop.sh
1 #!/bin/sh
2
3 # This program tests the LOOP command
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
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR" 
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 activity="create prog"
63 cat > $TEMPDIR/loop.stat <<EOF
64 data list notable /x 1 y 2 z 3.
65 begin data.
66 121
67 252
68 393
69 404
70 end data.
71
72 echo 'Loop with index'.
73 loop #i=x to y by z.
74 print /#i.
75 end loop.
76 print/'--------'.
77 execute.
78
79 echo 'Loop with IF condition'.
80 compute #j=x.
81 loop if #j <= y.
82 print /#j.
83 compute #j = #j + z.
84 end loop.
85 print/'--------'.
86 execute.
87
88 echo 'Loop with END IF condition'.
89 compute #k=x.
90 loop.
91 print /#k.
92 compute #k = #k + z.
93 end loop if #k > y.
94 print/'--------'.
95 execute.
96
97 echo 'Loop with index and IF condition based on index'.
98 loop #m=x to y by z if #m < 4.
99 print /#m.
100 end loop.
101 print/'--------'.
102 execute.
103
104 echo 'Loop with index and END IF condition based on index'.
105 loop #n=x to y by z.
106 print /#n.
107 end loop if #n >= 4.
108 print/'--------'.
109 execute.
110
111 echo 'Loop with index and IF and END IF condition based on index'.
112 loop #o=x to y by z if mod(#o,2) = 0.
113 print /#o.
114 end loop if #o >= 4.
115 print/'--------'.
116 execute.
117
118 echo 'Loop with no conditions'.
119 set mxloops = 2.
120 compute #p = x.
121 loop.
122 print /#p.
123 compute #p = #p + z.
124 do if #p >= y.
125 break.
126 end if.
127 end loop.
128 print/'--------'.
129 execute.
130 EOF
131 if [ $? -ne 0 ] ; then no_result ; fi
132
133 activity="run program"
134 $SUPERVISOR $PSPP --testing-mode -e $TEMPDIR/stdout $TEMPDIR/loop.stat 
135 if [ $? -ne 0 ] ; then no_result ; fi
136
137 activity="compare stdout"
138 perl -pi -e 's/^\s*$//g' $TEMPDIR/stdout
139 diff -b $TEMPDIR/stdout  - <<EOF
140 EOF
141 if [ $? -ne 0 ] ; then fail ; fi
142
143 activity="compare results"
144 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
145 diff  -b $TEMPDIR/pspp.list  - <<EOF
146 Loop with index
147     1.00 
148     2.00 
149 --------
150     2.00 
151     4.00 
152 --------
153     3.00 
154     6.00 
155     9.00 
156 --------
157 --------
158 Loop with IF condition
159     1.00 
160     2.00 
161 --------
162     2.00 
163     4.00 
164 --------
165     3.00 
166     6.00 
167     9.00 
168 --------
169 --------
170 Loop with END IF condition
171     1.00 
172     2.00 
173 --------
174     2.00 
175     4.00 
176 --------
177     3.00 
178     6.00 
179     9.00 
180 --------
181     4.00 
182 --------
183 Loop with index and IF condition based on index
184     1.00 
185     2.00 
186 --------
187     2.00 
188 --------
189     3.00 
190 --------
191 --------
192 Loop with index and END IF condition based on index
193     1.00 
194     2.00 
195 --------
196     2.00 
197     4.00 
198 --------
199     3.00 
200     6.00 
201 --------
202 --------
203 Loop with index and IF and END IF condition based on index
204 --------
205     2.00 
206     4.00 
207 --------
208 --------
209 --------
210 Loop with no conditions
211     1.00 
212 --------
213     2.00 
214     4.00 
215 --------
216     3.00 
217     6.00 
218 --------
219     4.00 
220 --------
221 EOF
222 if [ $? -ne 0 ] ; then fail ; fi
223
224
225 pass;