Remove unneeded #includes.
[pspp] / tests / language / utilities / set.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
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.
8 dnl
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.
13 dnl
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/>.
16 dnl
17 AT_BANNER([SET])
18
19 # This crashed older versions of PSPP (bug #30682).
20 AT_SETUP([SET FORMAT to invalid output format])
21 AT_DATA([set.pspp], [dnl
22 DATA LIST LIST NOTABLE /x.
23 BEGIN DATA.
24 1
25 2
26 3
27 END DATA.
28 SET FORMAT F41.
29 DESCRIPTIVES /x.
30 ])
31 AT_CHECK([pspp -O format=csv set.pspp], [1], [dnl
32 "set.pspp:7.12-7.14: error: SET: Output format F41.0 specifies width 41, but F requires a width between 1 and 40.
33     7 | SET FORMAT F41.
34       |            ^~~"
35
36 Table: Descriptive Statistics
37 ,N,Mean,Std Dev,Minimum,Maximum
38 x,3,2.00,1.00,1.00,3.00
39 Valid N (listwise),3,,,,
40 Missing N (listwise),0,,,,
41 ])
42 AT_CLEANUP
43
44
45 dnl This scenario was observed to erroneously free things twice
46 AT_SETUP([SET crash on invalid cc])
47 AT_DATA([set.pspp], [dnl
48 SET CCA='xxxx'.SHGW CCA.
49 ])
50
51 AT_CHECK([pspp -O format=csv set.pspp], [1], [dnl
52 "set.pspp:1.9-1.14: error: SET: Custom currency string `CCA' for xxxx does not contain exactly three periods or commas (or it contains both).
53     1 | SET CCA='xxxx'.SHGW CCA.
54       |         ^~~~~~"
55 ])
56 AT_CLEANUP
57
58
59
60 AT_SETUP([SET MXWARNS])
61 dnl Make sure that syntax processing stops and that
62 dnl a warning is issued when the MXWARNS figure is
63 dnl exceeded.
64 AT_DATA([set.pspp], [dnl
65 set mxwarns=2.
66 data list notable list /x (f8.2) y (f8.2).
67 begin data
68 1 2
69 3 r
70 5 x
71 q 8
72 9 9
73 3 x
74 w w
75 end data.
76
77 comment The following line should not be executed.
78 list.
79 ])
80
81 AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
82 set.pspp:5.3: warning: Data for variable y is not valid as format F: Field contents are not numeric.
83
84 set.pspp:6.3: warning: Data for variable y is not valid as format F: Field contents are not numeric.
85
86 set.pspp:7.1: warning: Data for variable x is not valid as format F: Field contents are not numeric.
87
88 note: Warnings (3) exceed limit (2).  Syntax processing will be halted.
89 ])
90
91 AT_CLEANUP
92
93
94
95
96 AT_SETUP([SET MXWARNS special case zero])
97 dnl Make sure that MXWARNS interprets zero as infinity.
98 AT_DATA([mxwarns.pspp], [dnl
99 set mxwarns=0.
100 data list notable list /x (f8.2) y (f8.2) z *.
101 begin data
102 1 2 3
103 3 r 3
104 5 x 3
105 q 8 4
106 9 9 4
107 3 x 4
108 w w 4
109 end data.
110
111 list.
112 ])
113
114 AT_CHECK([pspp -O format=csv mxwarns.pspp], [0],
115 [warning: MXWARNS set to zero.  No further warnings will be given even when potentially problematic situations are encountered.
116
117 Table: Data List
118 x,y,z
119 1.00,2.00,3.00
120 3.00,.  ,3.00
121 5.00,.  ,3.00
122 .  ,8.00,4.00
123 9.00,9.00,4.00
124 3.00,.  ,4.00
125 .  ,.  ,4.00
126 ])
127
128 AT_CLEANUP
129
130 AT_SETUP([SET macro - MEXPAND MPRINT MITERATE MNEST])
131 AT_DATA([set-macro.sps], [dnl
132 show mexpand mprint miterate mnest.
133 preserve.
134 set mexpand=off mprint=on miterate=10 mnest=11.
135 show mexpand mprint miterate mnest.
136 restore.
137 show mexpand mprint miterate mnest.
138 ])
139 AT_CHECK([pspp -O format=csv set-macro.sps], [0], [dnl
140 Table: Settings
141 MEXPAND,ON
142 MPRINT,OFF
143 MITERATE,1000
144 MNEST,50
145
146 Table: Settings
147 MEXPAND,OFF
148 MPRINT,ON
149 MITERATE,10
150 MNEST,11
151
152 Table: Settings
153 MEXPAND,ON
154 MPRINT,OFF
155 MITERATE,1000
156 MNEST,50
157 ])
158 AT_CLEANUP
159
160 AT_SETUP([SET syntax errors])
161 AT_DATA([set.sps], [dnl
162 SET **.
163 SET BASETEXTDIRECTION=**.
164 SET BLANKS=**.
165 SET BOX=**.
166 SET CACHE=**.
167 SET CCA=**.
168 SET CELLSBREAK=**.
169 SET CMPTRANS=**.
170 SET COMPRESSION=**.
171 SET CTEMPLATE=**.
172 SET DECIMAL=**.
173 SET EPOCH=**.
174 SET EPOCH=1234.
175 SET ERRORS=**.
176 SET FORMAT=**.
177 SET FORMAT=A8.
178 SET FORMAT=F1.2.
179 SET FUZZBITS=40.
180 SET HEADER=**.
181 SET INCLUDE=**.
182 SET JOURNAL=**.
183 SET LEADZERO=**.
184 SET LENGTH=**.
185 SET LOCALE='Neverland'.
186 SET LOCALE=**.
187 SET MDISPLAY=**.
188 SET MESSAGES=**.
189 SET MEXPAND=**.
190 SET MITERATE=0.
191 SET MNEST=0.
192 SET MPRINT=**.
193 SET MXERRS=0.
194 SET MXLOOPS=0.
195 SET MXWARNS=-1.
196 SET PRINTBACK=**.
197 SET RESULTS=**.
198 SET RIB=**.
199 SET RRB=**.
200 SET SAFER=**.
201 SET SCOMPRESSION=**.
202 SET SEED=**.
203 SET SMALL=**.
204 SET SUBTITLE=**.
205 SET TNUMBERS=**.
206 SET TVARS=**.
207 SET TLOOK='nonexistent.xml'.
208 SET UNDEFINED=**.
209 SET WIB=**.
210 SET WRB=**.
211 SET WIDTH=**.
212 SET WORKSPACE=**.
213 ])
214 AT_CHECK([pspp -O format=csv set.sps], [1], [dnl
215 "set.sps:1.5-1.6: error: SET: Syntax error expecting the name of a setting.
216     1 | SET **.
217       |     ^~"
218
219 "set.sps:2.5-2.24: warning: SET: BASETEXTDIRECTION is not yet implemented.
220     2 | SET BASETEXTDIRECTION=**.
221       |     ^~~~~~~~~~~~~~~~~~~~"
222
223 "set.sps:3.12-3.13: error: SET: Syntax error expecting number.
224     3 | SET BLANKS=**.
225       |            ^~"
226
227 "set.sps:4.5-4.10: warning: SET: BOX is not yet implemented.
228     4 | SET BOX=**.
229       |     ^~~~~~"
230
231 "set.sps:5.5-5.12: warning: SET: CACHE is not yet implemented.
232     5 | SET CACHE=**.
233       |     ^~~~~~~~"
234
235 "set.sps:6.9-6.10: error: SET: Syntax error expecting string.
236     6 | SET CCA=**.
237       |         ^~"
238
239 "set.sps:7.5-7.17: warning: SET: CELLSBREAK is not yet implemented.
240     7 | SET CELLSBREAK=**.
241       |     ^~~~~~~~~~~~~"
242
243 "set.sps:8.5-8.15: warning: SET: CMPTRANS is not yet implemented.
244     8 | SET CMPTRANS=**.
245       |     ^~~~~~~~~~~"
246
247 "set.sps:9.5-9.18: warning: SET: COMPRESSION is not yet implemented.
248     9 | SET COMPRESSION=**.
249       |     ^~~~~~~~~~~~~~"
250
251 "set.sps:10.5-10.16: warning: SET: CTEMPLATE is not yet implemented.
252    10 | SET CTEMPLATE=**.
253       |     ^~~~~~~~~~~~"
254
255 "set.sps:11.13-11.14: error: SET: Syntax error expecting DOT or COMMA.
256    11 | SET DECIMAL=**.
257       |             ^~"
258
259 "set.sps:12.11-12.12: error: SET: Syntax error expecting AUTOMATIC or year.
260    12 | SET EPOCH=**.
261       |           ^~"
262
263 "set.sps:13.11-13.14: error: SET: Syntax error expecting integer 1500 or greater for EPOCH.
264    13 | SET EPOCH=1234.
265       |           ^~~~"
266
267 "set.sps:14.12-14.13: error: SET: Syntax error expecting ON, BOTH, TERMINAL, LISTING, OFF, or NONE.
268    14 | SET ERRORS=**.
269       |            ^~"
270
271 "set.sps:15.12-15.13: error: SET: Syntax error expecting valid format specifier.
272    15 | SET FORMAT=**.
273       |            ^~"
274
275 "set.sps:16.5-16.13: error: SET: FORMAT requires numeric output format as an argument.  Specified format A8 is of type string.
276    16 | SET FORMAT=A8.
277       |     ^~~~~~~~~"
278
279 "set.sps:17.12-17.15: error: SET: Output format F1.2 specifies 2 decimal places, but width 1 does not allow for any decimals.
280    17 | SET FORMAT=F1.2.
281       |            ^~~~"
282
283 "set.sps:18.14-18.15: error: SET: Syntax error expecting integer between 0 and 20 for FUZZBITS.
284    18 | SET FUZZBITS=40.
285       |              ^~"
286
287 "set.sps:19.5-19.13: warning: SET: HEADER is not yet implemented.
288    19 | SET HEADER=**.
289       |     ^~~~~~~~~"
290
291 "set.sps:20.13-20.14: error: SET: Syntax error expecting ON, YES, OFF, or NO.
292    20 | SET INCLUDE=**.
293       |             ^~"
294
295 "set.sps:21.13-21.14: error: SET: Syntax error expecting ON or OFF or a file name.
296    21 | SET JOURNAL=**.
297       |             ^~"
298
299 "set.sps:22.14-22.15: error: SET: Syntax error expecting ON, YES, OFF, or NO.
300    22 | SET LEADZERO=**.
301       |              ^~"
302
303 "set.sps:23.12-23.13: error: SET: Syntax error expecting positive integer for LENGTH.
304    23 | SET LENGTH=**.
305       |            ^~"
306
307 "set.sps:24.12-24.22: error: SET: Neverland is not a recognized encoding or locale name.
308    24 | SET LOCALE='Neverland'.
309       |            ^~~~~~~~~~~"
310
311 "set.sps:25.12-25.13: error: SET: Syntax error expecting string.
312    25 | SET LOCALE=**.
313       |            ^~"
314
315 "set.sps:26.14-26.15: error: SET: Syntax error expecting TEXT or TABLES.
316    26 | SET MDISPLAY=**.
317       |              ^~"
318
319 "set.sps:27.14-27.15: error: SET: Syntax error expecting ON, BOTH, TERMINAL, LISTING, OFF, or NONE.
320    27 | SET MESSAGES=**.
321       |              ^~"
322
323 "set.sps:28.13-28.14: error: SET: Syntax error expecting ON, YES, OFF, or NO.
324    28 | SET MEXPAND=**.
325       |             ^~"
326
327 "set.sps:29.14: error: SET: Syntax error expecting positive integer for MITERATE.
328    29 | SET MITERATE=0.
329       |              ^"
330
331 "set.sps:30.11: error: SET: Syntax error expecting positive integer for MNEST.
332    30 | SET MNEST=0.
333       |           ^"
334
335 "set.sps:31.12-31.13: error: SET: Syntax error expecting ON, YES, OFF, or NO.
336    31 | SET MPRINT=**.
337       |            ^~"
338
339 "set.sps:32.12: error: SET: Syntax error expecting positive integer for MXERRS.
340    32 | SET MXERRS=0.
341       |            ^"
342
343 "set.sps:33.13: error: SET: Syntax error expecting positive integer for MXLOOPS.
344    33 | SET MXLOOPS=0.
345       |             ^"
346
347 "set.sps:34.13-34.14: error: SET: Syntax error expecting non-negative integer for MXWARNS.
348    34 | SET MXWARNS=-1.
349       |             ^~"
350
351 "set.sps:35.15-35.16: error: SET: Syntax error expecting ON, BOTH, TERMINAL, LISTING, OFF, or NONE.
352    35 | SET PRINTBACK=**.
353       |               ^~"
354
355 "set.sps:36.13-36.14: error: SET: Syntax error expecting ON, BOTH, TERMINAL, LISTING, OFF, or NONE.
356    36 | SET RESULTS=**.
357       |             ^~"
358
359 "set.sps:37.9-37.10: error: SET: Syntax error expecting MSBFIRST, LSBFIRST, VAX, or NATIVE.
360    37 | SET RIB=**.
361       |         ^~"
362
363 "set.sps:38.9-38.10: error: SET: Syntax error expecting one of the following: NATIVE, ISL, ISB, IDL, IDB, VF, VD, VG, ZS.
364    38 | SET RRB=**.
365       |         ^~"
366
367 "set.sps:39.11-39.12: error: SET: Syntax error expecting ON or YES.
368    39 | SET SAFER=**.
369       |           ^~"
370
371 "set.sps:40.18-40.19: error: SET: Syntax error expecting ON, YES, OFF, or NO.
372    40 | SET SCOMPRESSION=**.
373       |                  ^~"
374
375 "set.sps:41.10-41.11: error: SET: Syntax error expecting number.
376    41 | SET SEED=**.
377       |          ^~"
378
379 "set.sps:42.11-42.12: error: SET: Syntax error expecting number.
380    42 | SET SMALL=**.
381       |           ^~"
382
383 "set.sps:43.5-43.12: error: SET: Syntax error expecting the name of a setting.
384    43 | SET SUBTITLE=**.
385       |     ^~~~~~~~"
386
387 "set.sps:44.14-44.15: error: SET: Syntax error expecting LABELS, VALUES, or BOTH.
388    44 | SET TNUMBERS=**.
389       |              ^~"
390
391 "set.sps:45.11-45.12: error: SET: Syntax error expecting LABELS, NAMES, or BOTH.
392    45 | SET TVARS=**.
393       |           ^~"
394
395 set.sps:46: error: SET: nonexistent.xml: not found
396
397 "set.sps:47.15-47.16: error: SET: Syntax error expecting WARN or NOWARN.
398    47 | SET UNDEFINED=**.
399       |               ^~"
400
401 "set.sps:48.9-48.10: error: SET: Syntax error expecting MSBFIRST, LSBFIRST, VAX, or NATIVE.
402    48 | SET WIB=**.
403       |         ^~"
404
405 "set.sps:49.9-49.10: error: SET: Syntax error expecting one of the following: NATIVE, ISL, ISB, IDL, IDB, VF, VD, VG, ZS.
406    49 | SET WRB=**.
407       |         ^~"
408
409 "set.sps:50.11-50.12: error: SET: Syntax error expecting integer 40 or greater for WIDTH.
410    50 | SET WIDTH=**.
411       |           ^~"
412
413 "set.sps:51.15-51.16: error: SET: Syntax error expecting integer 1024 or greater for WORKSPACE.
414    51 | SET WORKSPACE=**.
415       |               ^~"
416 ])
417 AT_CLEANUP
418 \f
419 AT_BANNER([PRESERVE and RESTORE])
420
421 AT_SETUP([PRESERVE of SET FORMAT])
422 AT_DATA([set.pspp], [dnl
423 SHOW FORMAT.
424 PRESERVE.
425 SET FORMAT F10.0.
426 SHOW FORMAT
427 RESTORE.
428 SHOW FORMAT.
429 ])
430 AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
431 Table: Settings
432 FORMAT,F8.2
433
434 Table: Settings
435 FORMAT,F10.0
436
437 Table: Settings
438 FORMAT,F8.2
439 ])
440 AT_CLEANUP