Added new tests
[pspp-builds.git] / tests / command / print.sh
1 #!/bin/sh
2
3 # This program tests the PRINT transformation
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 # Copy this file --- it's shared with another test
49 activity="create data"
50 cp $here/data-list.data $TEMPDIR
51 if [ $? -ne 0 ] ; then no_result ; fi
52
53
54 activity="create program"
55 cat > $TEMPFILE/print.stat <<EOF_print
56 title 'Test PRINT transformation'.
57
58 remark EOF
59 ----------------------------------------------------------------------
60 There is no test for DATA LIST FIXED since it is imagined that the
61 rest of the tests give it a pretty good workout.
62 ----------------------------------------------------------------------
63 EOF
64 remark EOF
65 ----------------------------------------------------------------------
66 Testing use of DATA LIST FREE.
67 ----------------------------------------------------------------------
68 EOF
69 data list free table file='$TEMPDIR/data-list.data'/A B C D.
70 print outfile="foo" table/A(f8.2) '/' B(e8.2) '/' C(n10) '/' D(rbhex16) '/'.
71 print space a.
72 print outfile="foo" /a b c d.
73 list.
74
75 remark EOF
76 ----------------------------------------------------------------------
77 Testing use of DATA LIST LIST.
78 ----------------------------------------------------------------------
79 EOF
80 data list list table file='$TEMPDIR/data-list.data'/A B C D.
81 print table/A B C D.
82 list.
83
84 EOF_print
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87
88 activity="run program"
89 $here/../src/pspp -o raw-ascii $TEMPFILE/print.stat > $TEMPDIR/errs
90 # Note   vv   --- there are errors in input.  Therefore, the  command must FAIL
91 if [ $? -eq 0 ] ; then fail ; fi
92
93 activity="compare error messages"
94 diff -w $TEMPDIR/errs - <<EOF
95 $TEMPDIR/data-list.data:1: error: (columns 1-5, field type F8.0)
96         Field does not form a valid floating-point constant.
97 $TEMPDIR/data-list.data:1: warning: LIST: The expression on PRINT
98         SPACE evaluated to -2147483648.  It's not possible to PRINT SPACE a
99         negative number of lines.
100 $TEMPDIR/data-list.data:2: error: (columns 1-8, field type F8.0)
101         Field does not form a valid floating-point constant.
102 $TEMPDIR/data-list.data:4: warning: LIST: The expression on PRINT
103         SPACE evaluated to -2147483648.  It's not possible to PRINT SPACE a
104         negative number of lines.
105 $TEMPDIR/data-list.data:4: error: (columns 3-12, field type F8.0)
106         Field does not form a valid floating-point constant.
107 $TEMPDIR/data-list.data:6: warning: LIST: The expression on PRINT
108         SPACE evaluated to -2147483648.  It's not possible to PRINT SPACE a
109         negative number of lines.
110 $TEMPDIR/data-list.data:1: error: (columns 1-5, field type F8.0)
111         Field does not form a valid floating-point constant.
112 $TEMPDIR/data-list.data:2: error: (columns 1-8, field type F8.0)
113         Field does not form a valid floating-point constant.
114 $TEMPDIR/data-list.data:2: warning: LIST: Missing value(s) for all
115         variables from C onward.  These will be filled with the system-missing
116         value or blanks, as appropriate.
117 $TEMPDIR/data-list.data:3: warning: LIST: Missing value(s) for all
118         variables from B onward.  These will be filled with the system-missing
119         value or blanks, as appropriate.
120 $TEMPDIR/data-list.data:4: error: (columns 3-12, field type F8.0)
121         Field does not form a valid floating-point constant.
122 $TEMPDIR/data-list.data:4: warning: LIST: Missing value(s) for all
123         variables from C onward.  These will be filled with the system-missing
124         value or blanks, as appropriate.
125 $TEMPDIR/data-list.data:5: warning: LIST: Missing value(s) for all
126         variables from C onward.  These will be filled with the system-missing
127         value or blanks, as appropriate.
128 $TEMPDIR/data-list.data:6: warning: LIST: Missing value(s) for all
129         variables from B onward.  These will be filled with the system-missing
130         value or blanks, as appropriate.
131 EOF
132 if [ $? -ne 0 ] ; then fail ; fi
133
134 cp $TEMPDIR/pspp.list /tmp/out
135 activity="compare output"
136 diff -b -B $TEMPDIR/pspp.list - << EOF
137 ----------------------------------------------------------------------
138 There is no test for DATA LIST FIXED since it is imagined that the
139 rest of the tests give it a pretty good workout.
140 ----------------------------------------------------------------------
141
142 ----------------------------------------------------------------------
143 Testing use of DATA LIST FREE.
144 ----------------------------------------------------------------------
145
146 1.1 DATA LIST.  Reading free-form data from file 
147 +--------+------+
148 |Variable|Format|
149 #========#======#
150 |A       |F8.0  |
151 |B       |F8.0  |
152 |C       |F8.0  |
153 |D       |F8.0  |
154 +--------+------+
155
156 2.1 PRINT.  Writing   1 records to file "foo".
157 +--------+------+-------+-------+
158 |Variable|Record|Columns| Format|
159 #========#======#=======#=======#
160 |A       |     1|  1-  8|F8.2   |
161 |"/"     |     1|  9-  9|A1     |
162 |B       |     1| 10- 17|E8.2   |
163 |"/"     |     1| 18- 18|A1     |
164 |C       |     1| 19- 28|N10.0  |
165 |"/"     |     1| 29- 29|A1     |
166 |D       |     1| 30- 45|RBHEX16|
167 |"/"     |     1| 46- 46|A1     |
168 +--------+------+-------+-------+
169
170
171        A        B        C        D
172 -------- -------- -------- --------
173      .       2.00     3.00     4.00 
174
175      .       6.00     7.00     8.00 
176
177      .      10.00    11.00    12.00 
178
179 ----------------------------------------------------------------------
180 Testing use of DATA LIST LIST.
181 ----------------------------------------------------------------------
182
183 3.1 DATA LIST.  Reading free-form data from file 
184 +--------+------+
185 |Variable|Format|
186 #========#======#
187 |A       |F8.0  |
188 |B       |F8.0  |
189 |C       |F8.0  |
190 |D       |F8.0  |
191 +--------+------+
192
193 4.1 PRINT.  Writing   1 records to the listing file.
194 +--------+------+-------+------+
195 |Variable|Record|Columns|Format|
196 #========#======#=======#======#
197 |A       |     1|  1-  8|F8.2  |
198 |B       |     1| 10- 17|F8.2  |
199 |C       |     1| 19- 26|F8.2  |
200 |D       |     1| 28- 35|F8.2  |
201 +--------+------+-------+------+
202      .       2.00     3.00     4.00 
203
204        A        B        C        D
205 -------- -------- -------- --------
206      .       2.00     3.00     4.00 
207      .       6.00      .        .   
208      .       6.00      .        .   
209     7.00      .        .        .   
210     7.00      .        .        .   
211     8.00      .        .        .   
212     8.00      .        .        .   
213    10.00    11.00      .        .   
214    10.00    11.00      .        .   
215    12.00      .        .        .   
216    12.00      .        .        .   
217 EOF
218 if [ $? -ne 0 ] ; then fail ; fi
219
220
221 activity="compare print out"
222 diff $TEMPDIR/foo - << EOF
223      .  /2.00E+00/0000000003/0000000000001040/
224      .       2.00     3.00     4.00 
225      .  /6.00E+00/0000000007/0000000000002040/
226      .       6.00     7.00     8.00 
227      .  /1.00E+01/0000000011/0000000000002840/
228      .      10.00    11.00    12.00 
229 EOF
230 if [ $? -ne 0 ] ; then fail ; fi
231
232 pass;