0c2239177e5f64eda18b05cf78aa3459ba8e7a97
[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 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 STAT_CONFIG_PATH=$top_srcdir/config
13 export STAT_CONFIG_PATH
14
15
16 cleanup()
17 {
18      cd /
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create program"
51 cat > $TEMPDIR/vectors.stat <<EOF
52 DATA LIST /N1 TO N5 1-5.
53 MISSING VALUES N1 TO N5 (3 THRU 5, 1).
54 BEGIN DATA.
55 12345
56 6789 
57 END DATA.
58
59 VECTOR N=N1 TO N5.
60 VECTOR X(5).
61 LOOP I=1 TO 5.
62 COMPUTE X(I)=N(I) + 1.
63 END LOOP.
64
65 FORMATS ALL (F2).
66
67 LIST.
68 EOF
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="run program"
72 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/vectors.stat > $TEMPDIR/vectors.err 2> $TEMPDIR/vectors.out
73 if [ $? -ne 0 ] ; then fail ; fi
74
75 activity="compare results"
76 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
77 diff -b  $TEMPDIR/pspp.list - <<EOF
78 1.1 DATA LIST.  Reading 1 record from INLINE.
79 +--------+------+-------+------+
80 |Variable|Record|Columns|Format|
81 #========#======#=======#======#
82 |N1      |     1|  1-  1|F1.0  |
83 |N2      |     1|  2-  2|F1.0  |
84 |N3      |     1|  3-  3|F1.0  |
85 |N4      |     1|  4-  4|F1.0  |
86 |N5      |     1|  5-  5|F1.0  |
87 +--------+------+-------+------+
88 N1 N2 N3 N4 N5 X1 X2 X3 X4 X5  I
89 -- -- -- -- -- -- -- -- -- -- --
90  1  2  3  4  5  .  3  .  .  .  5 
91  6  7  8  9  .  7  8  9 10  .  5 
92 EOF
93
94 if [ $? -ne 0 ] ; then no_result ; fi
95
96
97 if [ $? -ne 0 ] ; then fail ; fi
98
99
100
101 pass;