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