967dec5915909513a86c7ac69def135389934501
[pspp-builds.git] / tests / expressions / vectors.sh
1 #!/bin/sh
2
3 # This program tests use of vectors in expressions.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 # ensure that top_srcdir and top_builddir  are absolute
8 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 top_srcdir=`cd $top_srcdir; pwd`
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
13
14 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17 LANG=C
18 export LANG
19
20
21 cleanup()
22 {
23      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
24         echo "NOT cleaning $TEMPDIR" 
25         return ; 
26      fi
27      cd /
28      rm -rf $TEMPDIR
29 }
30
31
32 fail()
33 {
34     echo $activity
35     echo FAILED
36     cleanup;
37     exit 1;
38 }
39
40
41 no_result()
42 {
43     echo $activity
44     echo NO RESULT;
45     cleanup;
46     exit 2;
47 }
48
49 pass()
50 {
51     cleanup;
52     exit 0;
53 }
54
55 mkdir -p $TEMPDIR
56
57 cd $TEMPDIR
58
59 activity="create program"
60 cat > $TEMPDIR/vectors.stat <<EOF
61 DATA LIST /N1 TO N5 1-5.
62 MISSING VALUES N1 TO N5 (3 THRU 5, 1).
63 BEGIN DATA.
64 12345
65 6789 
66 END DATA.
67
68 VECTOR N=N1 TO N5.
69 VECTOR X(5).
70 LOOP I=1 TO 5.
71 COMPUTE X(I)=N(I) + 1.
72 END LOOP.
73
74 FORMATS ALL (F2).
75
76 LIST.
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="run program"
81 $SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/vectors.stat > $TEMPDIR/vectors.err 2> $TEMPDIR/vectors.out
82 if [ $? -ne 0 ] ; then fail ; fi
83
84 activity="compare results"
85 diff -c $TEMPDIR/pspp.csv - <<EOF
86 Table: Reading 1 record from INLINE.
87 Variable,Record,Columns,Format
88 N1,1,1-  1,F1.0
89 N2,1,2-  2,F1.0
90 N3,1,3-  3,F1.0
91 N4,1,4-  4,F1.0
92 N5,1,5-  5,F1.0
93
94 Table: Data List
95 N1,N2,N3,N4,N5,X1,X2,X3,X4,X5,I
96 1,2,3,4,5,.,3,.,.,.,5
97 6,7,8,9,.,7,8,9,10,.,5
98 EOF
99
100 if [ $? -ne 0 ] ; then no_result ; fi
101
102
103 if [ $? -ne 0 ] ; then fail ; fi
104
105
106
107 pass;