Checkin of new directory structure.
[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
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 program"
52 cat > $TEMPDIR/vectors.stat <<EOF
53 DATA LIST /N1 TO N5 1-5.
54 MISSING VALUES N1 TO N5 (3 THRU 5, 1).
55 BEGIN DATA.
56 12345
57 6789 
58 END DATA.
59
60 VECTOR N=N1 TO N5.
61 VECTOR X(5).
62 LOOP I=1 TO 5.
63 COMPUTE X(I)=N(I) + 1.
64 END LOOP.
65
66 FORMATS ALL (F2).
67
68 LIST.
69 EOF
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="run program"
73 $SUPERVISOR $top_builddir/src/pspp -o raw-ascii $TEMPDIR/vectors.stat > $TEMPDIR/vectors.err 2> $TEMPDIR/vectors.out
74 if [ $? -ne 0 ] ; then fail ; fi
75
76 activity="compare results"
77 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
78 diff -b  $TEMPDIR/pspp.list - <<EOF
79 1.1 DATA LIST.  Reading 1 record from INLINE.
80 +--------+------+-------+------+
81 |Variable|Record|Columns|Format|
82 #========#======#=======#======#
83 |N1      |     1|  1-  1|F1.0  |
84 |N2      |     1|  2-  2|F1.0  |
85 |N3      |     1|  3-  3|F1.0  |
86 |N4      |     1|  4-  4|F1.0  |
87 |N5      |     1|  5-  5|F1.0  |
88 +--------+------+-------+------+
89 N1 N2 N3 N4 N5 X1 X2 X3 X4 X5  I
90 -- -- -- -- -- -- -- -- -- -- --
91  1  2  3  4  5  .  3  .  .  .  5 
92  6  7  8  9  .  7  8  9 10  .  5 
93 EOF
94
95 if [ $? -ne 0 ] ; then no_result ; fi
96
97
98 if [ $? -ne 0 ] ; then fail ; fi
99
100
101
102 pass;