1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([PRINT and WRITE])
19 dnl These tests check unusual aspects of the PRINT and WRITE
22 dnl - PRINT puts spaces between variables, unless a format
23 dnl is specified explicitly.
25 dnl - WRITE doesn't put space between variables.
27 dnl - PRINT to an external file prefixes each line with a space.
29 dnl - PRINT EJECT to an external file indicates a formfeed by a "1"
30 dnl in the first column.
32 dnl - WRITE writes out spaces for system-missing values, not a period.
34 dnl - When no output is specified, an empty record is output.
36 AT_SETUP([PRINT numeric variables])
37 AT_DATA([print.sps], [dnl
38 data list notable /x y 1-2.
54 AT_CHECK([pspp -O format=csv print.sps], [0], [dnl
93 AT_SETUP([PRINT string variables])
94 AT_DATA([print.sps], [dnl
95 DATA LIST FREE /s8 (a8) s10 (a10) vl255 (a255) vl258 (a258).
99 AbbbbMaryHadALittleLambbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZ
100 AccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccZ
103 AmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmZ
104 AoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooWhyIsItSoZ
109 /s10 * vl255 * vl258 *.
113 AT_CHECK([pspp -O format=csv print.sps])
114 AT_CHECK([cat print.txt], [0], [dnl
115 AaaaaaaaaZ AbbbbMaryHadALittleLambbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZ AccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccZ @&t@
116 AnnnnnnnnZ AmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmZ AoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooWhyIsItSoZ @&t@
120 AT_SETUP([PRINT to file])
121 AT_DATA([print.sps], [dnl
122 data list notable /x y 1-2.
131 print outfile='print.out' /x y.
132 print eject outfile='print.out' /x y (f1,f1).
133 print outfile='print.out' /x '-' y.
134 print outfile='print.out'.
138 AT_CHECK([pspp -O format=csv print.sps])
139 AT_CHECK([cat print.out], [0], [dnl
163 dnl Tests for a bug which crashed when deallocating after a bad PRINT
165 AT_SETUP([PRINT crash bug])
166 AT_DATA([print.sps], [dnl
167 DATA LIST LIST NOTABLE /a * b *.
176 AT_CHECK([pspp -O format=csv print.sps], [1], [dnl
177 "print.sps:7.7-7.10: error: PRINT: Syntax error expecting OUTFILE, ENCODING, RECORDS, TABLE, or NOTABLE.
188 AT_SETUP([WRITE to file])
189 AT_DATA([write.sps], [dnl
190 data list notable /x y 1-2.
199 write outfile='write.out' /x y.
200 write outfile='write.out' /x y (2(f1)).
201 write outfile='write.out' /x '-' y.
202 write outfile='write.out'.
206 AT_CHECK([pspp -O format=csv write.sps])
207 AT_CHECK([cat write.out], [0], [dnl
231 AT_SETUP([PRINT overwrites file])
232 AT_DATA([output.txt], [abcdef
234 AT_DATA([print.sps], [dnl
235 DATA LIST NOTABLE/x 1.
239 PRINT OUTFILE='output.txt'/x.
242 AT_CHECK([pspp -O format=csv print.sps])
243 AT_CHECK([cat output.txt], [0], [ 5 @&t@
247 AT_SETUP([PRINT overwrites file atomically])
248 AT_DATA([output.txt], [abcdef
251 [[DATA LIST NOTABLE/x 1.
255 PRINT OUTFILE='output.txt'/x.
256 HOST COMMAND=['kill -TERM $PPID'].
258 AT_CHECK([pspp -O format=csv print.sps], [143], [], [ignore])
259 AT_CHECK([cat output.txt], [0], [abcdef
262 [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
265 AT_SETUP([PRINT to same file being read])
266 AT_DATA([data.txt], [5
268 AT_DATA([print.sps], [dnl
269 DATA LIST FILE='data.txt' NOTABLE/x 1.
271 PRINT OUTFILE='data.txt'/y.
274 AT_CHECK([pspp -O format=csv print.sps])
275 AT_CHECK([cat data.txt], [0], [ 6.00 @&t@
278 [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
281 AT_SETUP([PRINT to special file])
282 AT_SKIP_IF([test ! -c /dev/null])
283 AT_CHECK([ln -s /dev/null foo.out || exit 77])
284 AT_SKIP_IF([test ! -c foo.out])
285 AT_DATA([print.sps], [dnl
286 DATA LIST NOTABLE /x 1.
294 PRINT OUTFILE='foo.out'/x.
295 PRINT OUTFILE='foo2.out'/x.
298 AT_CHECK([pspp -O format=csv print.sps])
299 AT_CHECK([cat foo2.out], [0], [dnl
306 ls -l foo.out foo2.out
307 AT_CHECK([test -c foo.out])
310 AT_SETUP([PRINT with special line ends])
311 AT_DATA([print.sps], [dnl
312 FILE HANDLE lf /NAME='lf.txt' /ENDS=LF.
313 FILE HANDLE crlf /NAME='crlf.txt' /ENDS=CRLF.
314 DATA LIST NOTABLE /x 1.
323 PRINT OUTFILE=crlf/x.
326 AT_CHECK([pspp -O format=csv print.sps])
327 AT_CHECK([cat lf.txt], [0], [dnl
334 AT_CHECK([tr '\r' R < crlf.txt], [0], [dnl
343 AT_SETUP([PRINT syntax errors])
344 AT_DATA([print.sps], [dnl
345 DATA LIST LIST NOTABLE /x.
357 AT_CHECK([pspp -O format=csv print.sps], [1], [dnl
358 "print.sps:2.15-2.16: error: PRINT: Syntax error expecting a file name or handle name.
359 2 | PRINT OUTFILE=**.
362 "print.sps:3.16-3.17: error: PRINT: Syntax error expecting string.
363 3 | PRINT ENCODING=**.
366 "print.sps:4.15-4.16: error: PRINT: Syntax error expecting non-negative integer for RECORDS.
367 4 | PRINT RECORDS=-1.
370 "print.sps:5.7-5.8: error: PRINT: Syntax error expecting OUTFILE, ENCODING, RECORDS, TABLE, or NOTABLE.
374 "print.sps:6.8-6.9: error: PRINT: Syntax error expecting variable name.
378 "print.sps:7.16: error: PRINT: Column positions for fields must be positive.
379 7 | PRINT/'string' 0.
382 "print.sps:8.16-8.18: error: PRINT: The ending column for a field must be greater than the starting column.
383 8 | PRINT/'string' 5-3.
386 "print.sps:9.7: error: PRINT: y is not a variable name.
390 "print.sps:10.9: error: PRINT: Column positions for fields must be positive.
394 "print.sps:11.9-11.12: error: PRINT: Numeric variable x is not compatible with string format A8.