Move all command implementations into a single 'commands' directory.
[pspp] / tests / language / commands / aggregate.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([AGGREGATE procedure])
18
19 dnl CHECK_AGGREGATE(OUTFILE, SORT, MISSING)
20 dnl
21 dnl Checks the AGGREGATE procedure with the specified combination of:
22 dnl
23 dnl - OUTFILE: One of "dataset", "active", or "external" according to
24 dnl   where AGGREGATE's output should be directed.
25 dnl
26 dnl - SORT: Either "presorted" or "unsorted" according to whether
27 dnl   AGGREGATE should received presorted input.
28 dnl
29 dnl - MISSING: Either "itemwise" or "columnwise" according to the basis
30 dnl   on which missing values should be eliminated.
31 dnl
32 m4_define([CHECK_AGGREGATE], [
33   AT_SETUP([AGGREGATE $2 data to $1 file, $3 missing])
34   AT_DATA([aggregate.data],
35   [2 42
36 1001
37 4 41
38 3112
39 1112
40 2661
41 1221
42 2771
43 1331
44 1441
45 2881
46 1551
47 ])
48   AT_DATA([aggregate.sps],
49     [DATA LIST NOTABLE FILE='aggregate.data' /G N 1-2 S 3(a) W 4.
50 WEIGHT BY w.
51 MISSING VALUES n(4) s('4').
52 m4_if([$1], [dataset], [DATASET DECLARE aggregate.])
53 m4_if([$2], [presorted], [SORT CASES BY g.])
54 AGGREGATE dnl
55 m4_if([$1], [active], [OUTFILE=*],
56       [$1], [external], [OUTFILE='aggregate.sys'],
57       [outfile=aggregate]) dnl
58 m4_if([$3], [columnwise], [/MISSING=COLUMNWISE])
59 m4_if([$2], [presorted], [/PRESORTED]) dnl
60         /DOCUMENT
61         /BREAK=g
62         /N = n
63         /NI = n./
64         NU = nu
65         /NUI = nu./
66         NFGT2 = fgt(n, 2)
67         /NFGT2I = fgt.(n, 2)
68         /SFGT2 = fgt(s, '2')
69         /SFGT2I = fgt.(s, '2')
70         /NFIN23 = fin(n, 2, 3)
71         /NFIN23I = fin.(n, 2, 3)
72         /SFIN23 = fin(s, '2', '3')
73         /SFIN23I = fin.(s, '2', '3')
74         /NFLT2 = flt(n, 2)
75         /NFLT2I = flt.(n, 2)
76         /SFLT2 = flt(s, '2')
77         /SFLT2I = flt.(s, '2')
78         /NFIRST = first(n)
79         /NFIRSTI = first.(n)
80         /SFIRST = first(s)
81         /SFIRSTI = first.(s)
82         /NFOUT23 = fout(n, 3, 2)
83         /NFOUT23I = fout.(n, 3, 2)
84         /SFOUT23 = fout(s, '3', '2')
85         /SFOUT23I = fout.(s, '3', '2')
86         /NLAST = last(n)
87         /NLASTI = last.(n)
88         /SLAST = last(s)
89         /SLASTI = last.(s)
90         /NMAX = max(n)
91         /NMAXI = max.(n)
92         /SMAX = max(s)
93         /SMAXI = max.(s)
94         /NMEAN = mean(n)
95         /NMEANI = mean.(n)
96         /NMIN = min(n)
97         /NMINI = min.(n)
98         /SMIN = min(s)
99         /SMINI = min.(s)
100         /NN = n(n)
101         /NNI = n.(n)
102         /SN = n(s)
103         /SNI = n.(s)
104         /NNMISS = nmiss(n)
105         /NNMISSI = nmiss.(n)
106         /SNMISS = nmiss(s)
107         /SNMISSI = nmiss.(s)
108         /NNU = nu(n)
109         /NNUI = nu.(n)
110         /SNU = nu(s)
111         /SNUI = nu.(s)
112         /NNUMISS = numiss(n)
113         /NNUMISSI = numiss.(n)
114         /SNUMISS = numiss(s)
115         /SNUMISSI = numiss.(s)
116         /NPGT2 = pgt(n, 2)
117         /NPGT2I = pgt.(n, 2)
118         /SPGT2 = pgt(s, '2')
119         /SPGT2I = pgt.(s, '2')
120         /NPIN23 = pin(n, 2, 3)
121         /NPIN23I = pin.(n, 2, 3)
122         /SPIN23 = pin(s, '2', '3')
123         /SPIN23I = pin.(s, '2', '3')
124         /NPLT2 = plt(n, 2)
125         /NPLT2I = plt.(n, 2)
126         /SPLT2 = plt(s, '2')
127         /SPLT2I = plt.(s, '2')
128         /NPOUT23 = pout(n, 2, 3)
129         /NPOUT23I = pout.(n, 2, 3)
130         /SPOUT23 = pout(s, '2', '3')
131         /SPOUT23I = pout.(s, '2', '3')
132         /NMEDIAN = median(n)
133         /NMEDIANI = median.(n)
134         /NSD = sd(n)
135         /NSDI = sd.(n)
136         /NSUM = sum(n)
137         /NSUMI = sum.(n).
138 m4_if([$1], [external], [GET FILE='aggregate.sys'.],
139       [$1], [dataset], [DATASET ACTIVATE aggregate.])
140 LIST.
141 ])
142   AT_CHECK([pspp -O format=csv aggregate.sps], [0], 
143     [m4_if([$3], [itemwise], [dnl
144 "aggregate.sps:29.28-29.31: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
145    29 |         /NFOUT23 = fout(n, 3, 2)
146       |                            ^~~~"
147  
148 "aggregate.sps:30.30-30.33: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
149    30 |         /NFOUT23I = fout.(n, 3, 2)
150       |                              ^~~~"
151  
152 "aggregate.sps:31.28-31.35: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
153    31 |         /SFOUT23 = fout(s, '3', '2')
154       |                            ^~~~~~~~"
155  
156 "aggregate.sps:32.30-32.37: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
157    32 |         /SFOUT23I = fout.(s, '3', '2')
158       |                              ^~~~~~~~"
159
160 Table: Data List
161 G,N,NI,NU,NUI,NFGT2,NFGT2I,SFGT2,SFGT2I,NFIN23,NFIN23I,SFIN23,SFIN23I,NFLT2,NFLT2I,SFLT2,SFLT2I,NFIRST,NFIRSTI,SFIRST,SFIRSTI,NFOUT23,NFOUT23I,SFOUT23,SFOUT23I,NLAST,NLASTI,SLAST,SLASTI,NMAX,NMAXI,SMAX,SMAXI,NMEAN,NMEANI,NMIN,NMINI,SMIN,SMINI,NN,NNI,SN,SNI,NNMISS,NNMISSI,SNMISS,SNMISSI,NNU,NNUI,SNU,SNUI,NNUMISS,NNUMISSI,SNUMISS,SNUMISSI,NPGT2,NPGT2I,SPGT2,SPGT2I,NPIN23,NPIN23I,SPIN23,SPIN23I,NPLT2,NPLT2I,SPLT2,SPLT2I,NPOUT23,NPOUT23I,SPOUT23,SPOUT23I,NMEDIAN,NMEDIANI,NSD,NSDI,NSUM,NSUMI
162 1,7.00,7.00,6,6,.333,.429,.333,.429,.333,.286,.333,.286,.500,.429,.500,.429,0,0,0,0,.667,.714,.667,.714,5,5,5,5,5,5,5,5,2.00,2.29,0,0,0,0,6.00,7.00,6.00,7.00,1.00,.00,1.00,.00,5,6,5,6,1,0,1,0,33.3,42.9,33.3,42.9,33.3,28.6,33.3,28.6,50.0,42.9,50.0,42.9,66.7,71.4,66.7,71.4,1.50,2.00,1.79,1.80,12.00,16.00
163 2,5.00,5.00,4,4,1.000,1.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,6,6,6,4,1.000,1.000,1.000,1.000,8,8,8,8,8,8,8,8,7.00,7.00,6,6,6,4,3.00,3.00,3.00,5.00,2.00,2.00,2.00,.00,3,3,3,4,1,1,1,0,100.0,100.0,100.0,100.0,.0,.0,.0,.0,.0,.0,.0,.0,100.0,100.0,100.0,100.0,7.00,7.00,1.00,1.00,21.00,21.00
164 3,2.00,2.00,1,1,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,1.000,1.000,1,1,1,1,1.000,1.000,1.000,1.000,1,1,1,1,1,1,1,1,1.00,1.00,1,1,1,1,2.00,2.00,2.00,2.00,.00,.00,.00,.00,1,1,1,1,0,0,0,0,.0,.0,.0,.0,.0,.0,.0,.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,1.00,1.00,.00,.00,2.00,2.00
165 4,1.00,1.00,1,1,.   ,.   ,.   ,1.000,.   ,.   ,.   ,.000,.   ,.   ,.   ,.000,.,.,,4,.   ,.   ,.   ,1.000,.,.,,4,.,.,,4,.  ,.  ,.,.,,4,.00,.00,.00,1.00,1.00,1.00,1.00,.00,0,0,0,1,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,NaN,NaN,.  ,.  ,.  ,.  @&t@
166 ],
167       [dnl
168 "aggregate.sps:29.28-29.31: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
169    29 |         /NFOUT23 = fout(n, 3, 2)
170       |                            ^~~~"
171  
172 "aggregate.sps:30.30-30.33: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
173    30 |         /NFOUT23I = fout.(n, 3, 2)
174       |                              ^~~~"
175  
176 "aggregate.sps:31.28-31.35: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
177    31 |         /SFOUT23 = fout(s, '3', '2')
178       |                            ^~~~~~~~"
179  
180 "aggregate.sps:32.30-32.37: warning: AGGREGATE: The value arguments passed to the FOUT function are out of order.  They will be treated as if they had been specified in the correct order.
181    32 |         /SFOUT23I = fout.(s, '3', '2')
182       |                              ^~~~~~~~"
183
184 Table: Data List
185 G,N,NI,NU,NUI,NFGT2,NFGT2I,SFGT2,SFGT2I,NFIN23,NFIN23I,SFIN23,SFIN23I,NFLT2,NFLT2I,SFLT2,SFLT2I,NFIRST,NFIRSTI,SFIRST,SFIRSTI,NFOUT23,NFOUT23I,SFOUT23,SFOUT23I,NLAST,NLASTI,SLAST,SLASTI,NMAX,NMAXI,SMAX,SMAXI,NMEAN,NMEANI,NMIN,NMINI,SMIN,SMINI,NN,NNI,SN,SNI,NNMISS,NNMISSI,SNMISS,SNMISSI,NNU,NNUI,SNU,SNUI,NNUMISS,NNUMISSI,SNUMISS,SNUMISSI,NPGT2,NPGT2I,SPGT2,SPGT2I,NPIN23,NPIN23I,SPIN23,SPIN23I,NPLT2,NPLT2I,SPLT2,SPLT2I,NPOUT23,NPOUT23I,SPOUT23,SPOUT23I,NMEDIAN,NMEDIANI,NSD,NSDI,NSUM,NSUMI
186 1,7.00,7.00,6,6,.   ,.429,.   ,.429,.   ,.286,.   ,.286,.   ,.429,.   ,.429,.,0,,0,.   ,.714,.   ,.714,.,5,,5,.,5,,5,.  ,2.29,.,0,,0,6.00,7.00,6.00,7.00,1.00,.00,1.00,.00,5,6,5,6,1,0,1,0,. ,42.9,. ,42.9,. ,28.6,. ,28.6,. ,42.9,. ,42.9,. ,71.4,. ,71.4,.  ,2.00,.  ,1.80,.  ,16.00
187 2,5.00,5.00,4,4,.   ,.   ,.   ,1.000,.   ,.   ,.   ,.000,.   ,.   ,.   ,.000,.,.,,4,.   ,.   ,.   ,1.000,.,.,,8,.,.,,8,.  ,.  ,.,.,,4,3.00,3.00,3.00,5.00,2.00,2.00,2.00,.00,3,3,3,4,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,.  ,.  ,.  ,.  ,.  ,.  @&t@
188 3,2.00,2.00,1,1,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,1.000,1.000,1,1,1,1,1.000,1.000,1.000,1.000,1,1,1,1,1,1,1,1,1.00,1.00,1,1,1,1,2.00,2.00,2.00,2.00,.00,.00,.00,.00,1,1,1,1,0,0,0,0,.0,.0,.0,.0,.0,.0,.0,.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,1.00,1.00,.00,.00,2.00,2.00
189 4,1.00,1.00,1,1,.   ,.   ,.   ,1.000,.   ,.   ,.   ,.000,.   ,.   ,.   ,.000,.,.,,4,.   ,.   ,.   ,1.000,.,.,,4,.,.,,4,.  ,.  ,.,.,,4,.00,.00,.00,1.00,1.00,1.00,1.00,.00,0,0,0,1,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,.  ,.  ,.  ,.  ,.  ,.  @&t@
190 ])])
191   AT_CLEANUP])
192
193 CHECK_AGGREGATE([dataset], [presorted], [itemwise])
194 CHECK_AGGREGATE([dataset], [presorted], [columnwise])
195 CHECK_AGGREGATE([dataset], [unsorted], [itemwise])
196 CHECK_AGGREGATE([dataset], [unsorted], [columnwise])
197 CHECK_AGGREGATE([active], [presorted], [itemwise])
198 CHECK_AGGREGATE([active], [presorted], [columnwise])
199 CHECK_AGGREGATE([active], [unsorted], [itemwise])
200 CHECK_AGGREGATE([active], [unsorted], [columnwise])
201 CHECK_AGGREGATE([external], [presorted], [itemwise])
202 CHECK_AGGREGATE([external], [presorted], [columnwise])
203 CHECK_AGGREGATE([external], [unsorted], [itemwise])
204 CHECK_AGGREGATE([external], [unsorted], [columnwise])
205
206 AT_SETUP([AGGREGATE crash with MAX function])
207 AT_DATA([aggregate.sps],
208   [DATA LIST LIST /X (F8.2) Y (a25).
209
210 BEGIN DATA.
211 87.50 foo
212 87.34 bar
213 1 bar
214 END DATA.
215
216 AGGREGATE OUTFILE=* /BREAK=y /X=MAX(x).
217 LIST /x y.
218 ])
219 AT_CHECK([pspp -O format=csv aggregate.sps], [0],
220   [Table: Reading free-form data from INLINE.
221 Variable,Format
222 X,F8.2
223 Y,A25
224
225 Table: Data List
226 X,Y
227 87.34,bar
228 87.50,foo
229 ])
230 AT_CLEANUP
231
232 AT_SETUP([AGGREGATE crash with invalid syntax])
233 AT_DATA([aggregate.sps],
234   [INPUT PROGRAM.
235 LOOP c=1 TO 20.
236   COMPUTE x=UNIFORM(10)
237   END CASE.
238 END LOOP.
239 END FILE.
240 END INPUT PROGRAM.
241
242 AGGREGATE /BREAK=x .
243 ])
244 AT_CHECK([pspp -O format=csv aggregate.sps], [1], [ignore], [])
245 AT_CLEANUP
246
247
248 AT_SETUP([AGGREGATE mode=addvariables])
249 AT_DATA([addvariables.sps],
250   [data list notable list /x * cn * y *.
251 begin data.
252 1 1 2
253 3 2 3
254 3 3 4
255 5 4 6
256 7 5 8
257 7 6 9
258 7 7 20
259 9 8 11
260 end data.
261
262 aggregate outfile=* mode=addvariables
263         /break = x
264         /sum = sum(y)
265         /mean = mean (y)
266         /median = median (y).
267
268 list.
269 ])
270
271 AT_CHECK([pspp -O format=csv addvariables.sps], [0],
272   [Table: Data List
273 x,cn,y,sum,mean,median
274 1.00,1.00,2.00,2.00,2.00,2.00
275 3.00,2.00,3.00,7.00,3.50,3.50
276 3.00,3.00,4.00,7.00,3.50,3.50
277 5.00,4.00,6.00,6.00,6.00,6.00
278 7.00,5.00,8.00,37.00,12.33,9.00
279 7.00,6.00,9.00,37.00,12.33,9.00
280 7.00,7.00,20.00,37.00,12.33,9.00
281 9.00,8.00,11.00,11.00,11.00,11.00
282 ])
283
284 AT_CLEANUP
285
286 AT_SETUP([AGGREGATE duplicate variable errors])
287 AT_DATA([insert.sps], [dnl
288 INSERT FILE='aggregate.sps' ERROR=IGNORE.
289 ])
290 AT_DATA([aggregate.sps], [dnl
291 DATA LIST NOTABLE LIST /x.
292 AGGREGATE OUTFILE=* /BREAK=x /x=N.
293 AGGREGATE OUTFILE=* MODE=ADDVARIABLES /x=N.
294 AGGREGATE OUTFILE=* MODE=ADDVARIABLES /y=N /y=N.
295 ])
296 AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
297 "aggregate.sps:2.31: error: AGGREGATE: Variable name x duplicates the name of a break variable.
298     2 | AGGREGATE OUTFILE=* /BREAK=x /x=N.
299       |                               ^"
300
301 "aggregate.sps:3.40: error: AGGREGATE: Variable name x duplicates the name of a variable in the active file dictionary.
302     3 | AGGREGATE OUTFILE=* MODE=ADDVARIABLES /x=N.
303       |                                        ^"
304
305 "aggregate.sps:4.45: error: AGGREGATE: Duplicate target variable name y.
306     4 | AGGREGATE OUTFILE=* MODE=ADDVARIABLES /y=N /y=N.
307       |                                             ^"
308 ])
309 AT_CLEANUP
310
311 AT_SETUP([AGGREGATE presorted warnings])
312 AT_DATA([insert.sps], [dnl
313 INSERT FILE='aggregate.sps' ERROR=IGNORE.
314 ])
315 AT_DATA([aggregate.sps], [dnl
316 DATA LIST NOTABLE LIST /x.
317 AGGREGATE/PRESORTED/BREAK=x(A).
318 AGGREGATE/BREAK=x(A).
319 AGGREGATE/OUTFILE=* MODE=ADDVARIABLES/BREAK=x(A).
320 ])
321 AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
322 "aggregate.sps:2.27-2.30: warning: AGGREGATE: When the input data is presorted, specifying sorting directions with (A) or (D) has no effect.  Output data will be sorted the same way as the input data.
323     2 | AGGREGATE/PRESORTED/BREAK=x(A).
324       |                           ^~~~"
325
326 "aggregate.sps:2.11-2.19: note: AGGREGATE: The PRESORTED subcommand state that the input data is presorted.
327     2 | AGGREGATE/PRESORTED/BREAK=x(A).
328       |           ^~~~~~~~~"
329
330 "aggregate.sps:2.31: error: AGGREGATE: Syntax error expecting `/'.
331     2 | AGGREGATE/PRESORTED/BREAK=x(A).
332       |                               ^"
333
334 "aggregate.sps:3.17-3.20: warning: AGGREGATE: When the input data is presorted, specifying sorting directions with (A) or (D) has no effect.  Output data will be sorted the same way as the input data.
335     3 | AGGREGATE/BREAK=x(A).
336       |                 ^~~~"
337
338 aggregate.sps:3: note: AGGREGATE: The input data must be presorted because the OUTFILE subcommand is not specified.
339
340 "aggregate.sps:3.21: error: AGGREGATE: Syntax error expecting `/'.
341     3 | AGGREGATE/BREAK=x(A).
342       |                     ^"
343
344 "aggregate.sps:4.45-4.48: warning: AGGREGATE: When the input data is presorted, specifying sorting directions with (A) or (D) has no effect.  Output data will be sorted the same way as the input data.
345     4 | AGGREGATE/OUTFILE=* MODE=ADDVARIABLES/BREAK=x(A).
346       |                                             ^~~~"
347
348 "aggregate.sps:4.26-4.37: note: AGGREGATE: ADDVARIABLES implies that the input data is presorted.
349     4 | AGGREGATE/OUTFILE=* MODE=ADDVARIABLES/BREAK=x(A).
350       |                          ^~~~~~~~~~~~"
351
352 "aggregate.sps:4.49: error: AGGREGATE: Syntax error expecting `/'.
353     4 | AGGREGATE/OUTFILE=* MODE=ADDVARIABLES/BREAK=x(A).
354       |                                                 ^"
355 ])
356 AT_CLEANUP
357
358 AT_SETUP([AGGREGATE - subcommand syntax errors])
359 AT_DATA([insert.sps], [dnl
360 INSERT FILE='aggregate.sps' ERROR=IGNORE.
361 ])
362 AT_DATA([aggregate.sps], [dnl
363 DATA LIST NOTABLE LIST /x.
364 AGGREGATE OUTFILE=**.
365 AGGREGATE OUTFILE=* MODE=**.
366 AGGREGATE /MISSING=**.
367 AGGREGATE /BREAK=**.
368 ])
369 AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
370 "aggregate.sps:2.19-2.20: error: AGGREGATE: Syntax error expecting a file name or handle name.
371     2 | AGGREGATE OUTFILE=**.
372       |                   ^~"
373
374 "aggregate.sps:3.26-3.27: error: AGGREGATE: Syntax error expecting ADDVARIABLES or REPLACE.
375     3 | AGGREGATE OUTFILE=* MODE=**.
376       |                          ^~"
377
378 "aggregate.sps:4.20-4.21: error: AGGREGATE: Syntax error expecting COLUMNWISE.
379     4 | AGGREGATE /MISSING=**.
380       |                    ^~"
381
382 "aggregate.sps:5.18-5.19: error: AGGREGATE: Syntax error expecting variable name.
383     5 | AGGREGATE /BREAK=**.
384       |                  ^~"
385 ])
386 AT_CLEANUP
387
388 AT_SETUP([AGGREGATE - aggregation function syntax errors])
389 AT_DATA([insert.sps], [dnl
390 INSERT FILE='aggregate.sps' ERROR=IGNORE.
391 ])
392 AT_DATA([aggregate.sps], [dnl
393 DATA LIST NOTABLE LIST /x (f8.2) s (a8).
394 AGGREGATE **.
395 AGGREGATE / **.
396 AGGREGATE /y.
397 AGGREGATE /y=**.
398 AGGREGATE /y=xyzzy.
399 AGGREGATE /y=mean.
400 AGGREGATE /y=mean(**).
401 AGGREGATE /y=fgt(x **).
402 AGGREGATE /y=fgt(x 'xyzzy').
403 AGGREGATE /y=fgt(s 1).
404 AGGREGATE /y=fgt(s x).
405 AGGREGATE /y=sum(s).
406 AGGREGATE /y=sum(x. /* )
407 AGGREGATE /y=min(x, s).
408 AGGREGATE /y t=min(x).
409 AGGREGATE /y=pin(x, 2, 1).
410 AGGREGATE /y=mean(x)**.
411 ])
412 AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
413 "aggregate.sps:2.11-2.12: error: AGGREGATE: Syntax error expecting `/'.
414     2 | AGGREGATE **.
415       |           ^~"
416
417 "aggregate.sps:3.13-3.14: error: AGGREGATE: Syntax error expecting variable name.
418     3 | AGGREGATE / **.
419       |             ^~"
420
421 "aggregate.sps:4.13: error: AGGREGATE: Syntax error expecting variable name.
422     4 | AGGREGATE /y.
423       |             ^"
424
425 "aggregate.sps:5.14-5.15: error: AGGREGATE: Syntax error expecting aggregation function.
426     5 | AGGREGATE /y=**.
427       |              ^~"
428
429 "aggregate.sps:6.14-6.18: error: AGGREGATE: Unknown aggregation function xyzzy.
430     6 | AGGREGATE /y=xyzzy.
431       |              ^~~~~"
432
433 "aggregate.sps:7.18: error: AGGREGATE: Syntax error expecting `('.
434     7 | AGGREGATE /y=mean.
435       |                  ^"
436
437 "aggregate.sps:8.19-8.20: error: AGGREGATE: Syntax error expecting variable name.
438     8 | AGGREGATE /y=mean(**).
439       |                   ^~"
440
441 "aggregate.sps:9.20-9.21: error: AGGREGATE: Missing argument 1 to FGT.
442     9 | AGGREGATE /y=fgt(x **).
443       |                    ^~"
444
445 aggregate.sps:10: error: AGGREGATE: Arguments to FGT must be of same type as source variables.
446
447 "aggregate.sps:10.20-10.26: note: AGGREGATE: The argument is a string.
448    10 | AGGREGATE /y=fgt(x 'xyzzy').
449       |                    ^~~~~~~"
450
451 "aggregate.sps:10.18: note: AGGREGATE: The variables are numeric.
452    10 | AGGREGATE /y=fgt(x 'xyzzy').
453       |                  ^"
454
455 aggregate.sps:11: error: AGGREGATE: Arguments to FGT must be of same type as source variables.
456
457 "aggregate.sps:11.20: note: AGGREGATE: The argument is numeric.
458    11 | AGGREGATE /y=fgt(s 1).
459       |                    ^"
460
461 "aggregate.sps:11.18: note: AGGREGATE: The variables have string type.
462    11 | AGGREGATE /y=fgt(s 1).
463       |                  ^"
464
465 "aggregate.sps:12.20: error: AGGREGATE: s and x are not the same type.  All variables in this variable list must be of the same type.  x will be omitted from the list.
466    12 | AGGREGATE /y=fgt(s x).
467       |                    ^"
468
469 "aggregate.sps:12.21: error: AGGREGATE: Missing argument 1 to FGT.
470    12 | AGGREGATE /y=fgt(s x).
471       |                     ^"
472
473 "aggregate.sps:13.18: warning: AGGREGATE: s is not a numeric variable.  It will not be included in the variable list.
474    13 | AGGREGATE /y=sum(s).
475       |                  ^"
476
477 "aggregate.sps:14.19: error: AGGREGATE: Syntax error expecting `)'.
478    14 | AGGREGATE /y=sum(x. /* )
479       |                   ^"
480
481 aggregate.sps:15: error: AGGREGATE: Number of source variables (2) does not match number of target variables (1).
482
483 "aggregate.sps:15.18-15.21: note: AGGREGATE: These are the source variables.
484    15 | AGGREGATE /y=min(x, s).
485       |                  ^~~~"
486
487 "aggregate.sps:15.12: note: AGGREGATE: These are the target variables.
488    15 | AGGREGATE /y=min(x, s).
489       |            ^"
490
491 aggregate.sps:16: error: AGGREGATE: Number of source variables (1) does not match number of target variables (2).
492
493 "aggregate.sps:16.20: note: AGGREGATE: These are the source variables.
494    16 | AGGREGATE /y t=min(x).
495       |                    ^"
496
497 "aggregate.sps:16.12-16.14: note: AGGREGATE: These are the target variables.
498    16 | AGGREGATE /y t=min(x).
499       |            ^~~"
500
501 "aggregate.sps:17.21-17.24: warning: AGGREGATE: The value arguments passed to the PIN function are out of order.  They will be treated as if they had been specified in the correct order.
502    17 | AGGREGATE /y=pin(x, 2, 1).
503       |                     ^~~~"
504
505 "aggregate.sps:18.1-18.9: error: AGGREGATE: Syntax error expecting `BEGIN DATA'.
506    18 | AGGREGATE /y=mean(x)**.
507       | ^~~~~~~~~"
508
509 "aggregate.sps:18.1-18.9: error: AGGREGATE: Syntax error expecting end of command.
510    18 | AGGREGATE /y=mean(x)**.
511       | ^~~~~~~~~"
512 ])
513 AT_CLEANUP