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