Internationalisation.
[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      cd /
27      rm -rf $TEMPDIR
28 }
29
30
31 fail()
32 {
33     echo $activity
34     echo FAILED
35     cleanup;
36     exit 1;
37 }
38
39
40 no_result()
41 {
42     echo $activity
43     echo NO RESULT;
44     cleanup;
45     exit 2;
46 }
47
48 pass()
49 {
50     cleanup;
51     exit 0;
52 }
53
54 mkdir -p $TEMPDIR
55
56 cd $TEMPDIR
57
58 activity="create prog"
59 cat > $TEMPDIR/loop.stat <<EOF
60 data list /X 1 Y 2 ZOOLOGICAL 3.
61 begin data.
62 125
63 256
64 397
65 401
66 end data.
67 loop iterative_Variable=y to zoological by abs(zoological-y)/(zoological-y).
68 print /x iterative_Variable.
69 break.          /* Generates warning.
70 end loop.
71 execute.
72 EOF
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 activity="run program"
76 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TEMPDIR/loop.stat > $TEMPDIR/stdout
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="compare stdout"
80 perl -pi -e 's/^\s*$//g' $TEMPDIR/stdout
81 diff -b $TEMPDIR/stdout  - <<EOF
82 EOF
83 if [ $? -ne 0 ] ; then fail ; fi
84
85 activity="compare results"
86 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
87 diff  -b $TEMPDIR/pspp.list  - <<EOF
88 1.1 DATA LIST.  Reading 1 record from INLINE.
89 +----------+------+-------+------+
90 | Variable |Record|Columns|Format|
91 #==========#======#=======#======#
92 |X         |     1|  1-  1|F1.0  |
93 |Y         |     1|  2-  2|F1.0  |
94 |ZOOLOGICAL|     1|  3-  3|F1.0  |
95 +----------+------+-------+------+
96 1     2.00 
97 2     5.00 
98 3     9.00 
99 4      .00 
100 EOF
101 if [ $? -ne 0 ] ; then fail ; fi
102
103
104 pass;