3 # This program tests the LOOP command
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
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
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
58 activity="create prog"
59 cat > $TEMPDIR/loop.stat <<EOF
60 data list notable /x 1 y 2 z 3.
68 echo 'Loop with index'.
75 echo 'Loop with IF condition'.
84 echo 'Loop with END IF condition'.
93 echo 'Loop with index and IF condition based on index'.
94 loop #m=x to y by z if #m < 4.
100 echo 'Loop with index and END IF condition based on index'.
107 echo 'Loop with index and IF and END IF condition based on index'.
108 loop #o=x to y by z if mod(#o,2) = 0.
114 echo 'Loop with no conditions'.
127 if [ $? -ne 0 ] ; then no_result ; fi
129 activity="run program"
130 $SUPERVISOR $PSPP --testing-mode -o raw-ascii -e $TEMPDIR/stdout $TEMPDIR/loop.stat
131 if [ $? -ne 0 ] ; then no_result ; fi
133 activity="compare stdout"
134 perl -pi -e 's/^\s*$//g' $TEMPDIR/stdout
135 diff -b $TEMPDIR/stdout - <<EOF
137 if [ $? -ne 0 ] ; then fail ; fi
139 activity="compare results"
140 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
141 diff -b $TEMPDIR/pspp.list - <<EOF
154 Loop with IF condition
166 Loop with END IF condition
179 Loop with index and IF condition based on index
188 Loop with index and END IF condition based on index
199 Loop with index and IF and END IF condition based on index
206 Loop with no conditions
218 if [ $? -ne 0 ] ; then fail ; fi