New hmap and hmapx hash table implementations.
[pspp-builds.git] / tests / command / vector.sh
1 #!/bin/sh
2
3 # This program tests the VECTOR command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR" 
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 activity="create prog"
63 cat > $TEMPDIR/vector.stat <<EOF
64 data list notable/x 1.
65 vector v(4).
66 display vector.
67
68 data list notable/x 1.
69 vector #vec(4, comma10.2).
70 display vector.
71
72 input program.
73 vector x(5).
74 data list/x5 x2 x3 x1 x4 1-5.
75 end input program.
76 display vector.
77
78 data list notable/u w x y z 1-5.
79 vector a=u to y.
80 vector b=x to z.
81 vector c=all.
82 display vector.
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="run program"
87 $SUPERVISOR $PSPP --testing-mode -e $TEMPDIR/stdout $TEMPDIR/vector.stat
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 activity="compare stdout"
91 perl -pi -e 's/^\s*$//g' $TEMPDIR/stdout
92 diff -b $TEMPDIR/stdout  - <<EOF
93 EOF
94 if [ $? -ne 0 ] ; then fail ; fi
95
96 activity="compare results"
97 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
98 diff  -b $TEMPDIR/pspp.list  - <<EOF
99 +------+--------+--------+------------+
100 |Vector|Position|Variable|Print Format|
101 #======#========#========#============#
102 |v     |       1|v1      |F8.2        |
103 |      |       2|v2      |F8.2        |
104 |      |       3|v3      |F8.2        |
105 |      |       4|v4      |F8.2        |
106 +------+--------+--------+------------+
107 +------+--------+--------+------------+
108 |Vector|Position|Variable|Print Format|
109 #======#========#========#============#
110 |#vec  |       1|#vec1   |COMMA10.2   |
111 |      |       2|#vec2   |COMMA10.2   |
112 |      |       3|#vec3   |COMMA10.2   |
113 |      |       4|#vec4   |COMMA10.2   |
114 +------+--------+--------+------------+
115 1.1 DATA LIST.  Reading 1 record from INLINE.
116 +--------+------+-------+------+
117 |Variable|Record|Columns|Format|
118 #========#======#=======#======#
119 |x5      |     1|  1-  1|F1.0  |
120 |x2      |     1|  2-  2|F1.0  |
121 |x3      |     1|  3-  3|F1.0  |
122 |x1      |     1|  4-  4|F1.0  |
123 |x4      |     1|  5-  5|F1.0  |
124 +--------+------+-------+------+
125 +------+--------+--------+------------+
126 |Vector|Position|Variable|Print Format|
127 #======#========#========#============#
128 |x     |       1|x1      |F8.2        |
129 |      |       2|x2      |F8.2        |
130 |      |       3|x3      |F8.2        |
131 |      |       4|x4      |F8.2        |
132 |      |       5|x5      |F8.2        |
133 +------+--------+--------+------------+
134 +------+--------+--------+------------+
135 |Vector|Position|Variable|Print Format|
136 #======#========#========#============#
137 |a     |       1|u       |F1.0        |
138 |      |       2|w       |F1.0        |
139 |      |       3|x       |F1.0        |
140 |      |       4|y       |F1.0        |
141 +------+--------+--------+------------+
142 |b     |       1|x       |F1.0        |
143 |      |       2|y       |F1.0        |
144 |      |       3|z       |F1.0        |
145 +------+--------+--------+------------+
146 |c     |       1|u       |F1.0        |
147 |      |       2|w       |F1.0        |
148 |      |       3|x       |F1.0        |
149 |      |       4|y       |F1.0        |
150 |      |       5|z       |F1.0        |
151 +------+--------+--------+------------+
152 EOF
153 if [ $? -ne 0 ] ; then fail ; fi
154
155
156 pass;