Enabled the autoscroll feature on the datasheet.
[pspp] / tests / command / do-if.sh
1 #!/bin/sh
2
3 # This program tests the DO IF command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 # ensure that top_builddir  are absolute
8 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 top_builddir=`cd $top_builddir; pwd`
11 PSPP=$top_builddir/src/ui/terminal/pspp
12
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22 cleanup()
23 {
24      cd /
25      #rm -rf $TEMPDIR
26 }
27
28
29 fail()
30 {
31     echo $activity
32     echo FAILED
33     cleanup;
34     exit 1;
35 }
36
37
38 no_result()
39 {
40     echo $activity
41     echo NO RESULT;
42     cleanup;
43     exit 2;
44 }
45
46 pass()
47 {
48     cleanup;
49     exit 0;
50 }
51
52 mkdir -p $TEMPDIR
53
54 cd $TEMPDIR
55
56 activity="generate input and expected output"
57 (for a in 0 1 ' '; do
58     for b in 0 1 ' '; do
59         for c in 0 1 ' '; do
60             for d in 0 1 ' '; do
61                 abcd=$a$b$c$d
62                 echo "$abcd" 1>&3
63                 if test "$a" = "1"; then
64                     echo " $abcd A"
65                 elif test "$a" = " "; then
66                     :
67                 elif test "$b" = "1"; then
68                     echo " $abcd B"
69                 elif test "$b" = " "; then
70                     :
71                 elif test "$c" = "1"; then
72                     echo " $abcd C"
73                 elif test "$c" = " "; then
74                     :
75                 elif test "$d" = "1"; then
76                     echo " $abcd D"
77                 elif test "$d" = " "; then
78                     :
79                 else
80                     echo " $abcd E"
81                 fi
82             done
83         done
84     done
85 done) >test1.expected 3>test1.data
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88 activity="create test1.pspp"
89 cat > test1.pspp <<EOF
90 DATA LIST FILE="test1.data"/A B C D 1-4 ABCD 1-4 (A).
91 DO IF A.
92 PRINT OUTFILE="test1.out"/ABCD 'A'.
93 ELSE IF B.
94 PRINT OUTFILE="test1.out"/ABCD 'B'.
95 ELSE IF C.
96 PRINT OUTFILE="test1.out"/ABCD 'C'.
97 ELSE IF D.
98 PRINT OUTFILE="test1.out"/ABCD 'D'.
99 ELSE.
100 PRINT OUTFILE="test1.out"/ABCD 'E'.
101 END IF.
102 EXECUTE.
103 EOF
104 if [ $? -ne 0 ] ; then no_result ; fi
105
106 activity="run test1"
107 $SUPERVISOR $PSPP --testing-mode test1.pspp
108 if [ $? -ne 0 ] ; then no_result ; fi
109
110 activity="compare test1 results"
111 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
112 diff -u $TEMPDIR/test1.out $TEMPDIR/test1.expected
113 if [ $? -ne 0 ] ; then fail ; fi
114
115 pass