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 at `F8.2': expecting a valid subcommand.
186 AT_SETUP([WRITE to file])
187 AT_DATA([write.sps], [dnl
188 data list notable /x y 1-2.
197 write outfile='write.out' /x y.
198 write outfile='write.out' /x y (2(f1)).
199 write outfile='write.out' /x '-' y.
200 write outfile='write.out'.
204 AT_CHECK([pspp -O format=csv write.sps])
205 AT_CHECK([cat write.out], [0], [dnl
229 AT_SETUP([PRINT overwrites file])
230 AT_DATA([output.txt], [abcdef
232 AT_DATA([print.sps], [dnl
233 DATA LIST NOTABLE/x 1.
237 PRINT OUTFILE='output.txt'/x.
240 AT_CHECK([pspp -O format=csv print.sps])
241 AT_CHECK([cat output.txt], [0], [ 5 @&t@
245 AT_SETUP([PRINT overwrites file atomically])
246 AT_DATA([output.txt], [abcdef
249 [[DATA LIST NOTABLE/x 1.
253 PRINT OUTFILE='output.txt'/x.
254 HOST COMMAND=['kill -TERM $PPID'].
256 AT_CHECK([pspp -O format=csv print.sps], [143], [], [ignore])
257 AT_CHECK([cat output.txt], [0], [abcdef
260 [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
263 AT_SETUP([PRINT to same file being read])
264 AT_DATA([data.txt], [5
266 AT_DATA([print.sps], [dnl
267 DATA LIST FILE='data.txt' NOTABLE/x 1.
269 PRINT OUTFILE='data.txt'/y.
272 AT_CHECK([pspp -O format=csv print.sps])
273 AT_CHECK([cat data.txt], [0], [ 6.00 @&t@
276 [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
279 AT_SETUP([PRINT to special file])
280 AT_SKIP_IF([test ! -c /dev/null])
281 AT_CHECK([ln -s /dev/null foo.out || exit 77])
282 AT_SKIP_IF([test ! -c foo.out])
283 AT_DATA([print.sps], [dnl
284 DATA LIST NOTABLE /x 1.
292 PRINT OUTFILE='foo.out'/x.
293 PRINT OUTFILE='foo2.out'/x.
296 AT_CHECK([pspp -O format=csv print.sps])
297 AT_CHECK([cat foo2.out], [0], [dnl
304 ls -l foo.out foo2.out
305 AT_CHECK([test -c foo.out])
308 AT_SETUP([PRINT with special line ends])
309 AT_DATA([print.sps], [dnl
310 FILE HANDLE lf /NAME='lf.txt' /ENDS=LF.
311 FILE HANDLE crlf /NAME='crlf.txt' /ENDS=CRLF.
312 DATA LIST NOTABLE /x 1.
321 PRINT OUTFILE=crlf/x.
324 AT_CHECK([pspp -O format=csv print.sps])
325 AT_CHECK([cat lf.txt], [0], [dnl
332 AT_CHECK([tr '\r' R < crlf.txt], [0], [dnl