Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[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 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create prog"
52 cat > $TEMPDIR/loop.stat <<EOF
53 data list /X 1 Y 2 ZOOLOGICAL 3.
54 begin data.
55 125
56 256
57 397
58 401
59 end data.
60 loop iterative_Variable=y to zoological by abs(zoological-y)/(zoological-y).
61 print /x iterative_Variable.
62 break.          /* Generates warning.
63 end loop.
64 execute.
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68 activity="run program"
69 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/loop.stat > $TEMPDIR/stdout
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="compare stdout"
73 diff -B -b $TEMPDIR/stdout  - <<EOF
74 $TEMPDIR/loop.stat:10: warning: BREAK: BREAK not enclosed in DO IF structure.
75 EOF
76 if [ $? -ne 0 ] ; then fail ; fi
77
78 activity="compare results"
79 diff -B -b $TEMPDIR/pspp.list  - <<EOF
80 1.1 DATA LIST.  Reading 1 record from the command file.
81 +----------+------+-------+------+
82 | Variable |Record|Columns|Format|
83 #==========#======#=======#======#
84 |X         |     1|  1-  1|F1.0  |
85 |Y         |     1|  2-  2|F1.0  |
86 |ZOOLOGICAL|     1|  3-  3|F1.0  |
87 +----------+------+-------+------+
88 1     2.00 
89 2     5.00 
90 3     9.00 
91 4      .00 
92 EOF
93 if [ $? -ne 0 ] ; then fail ; fi
94
95
96 pass;