X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Faggregate.at;h=e574fc51f3e835f5441004d1599e495cd30df7c9;hb=a1610f63ae0c6de973de7d35d977c6119eec06f6;hp=5e00965e2dd5b87f46cf0c1af067f6031290a1f7;hpb=5dda55a193943200dbb77705657da238bd7ab837;p=pspp diff --git a/tests/language/stats/aggregate.at b/tests/language/stats/aggregate.at index 5e00965e2d..e574fc51f3 100644 --- a/tests/language/stats/aggregate.at +++ b/tests/language/stats/aggregate.at @@ -1,12 +1,28 @@ +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl AT_BANNER([AGGREGATE procedure]) dnl CHECK_AGGREGATE(OUTFILE, SORT, MISSING) dnl dnl Checks the AGGREGATE procedure with the specified combination of: dnl -dnl - OUTFILE: One of "scratch", "active", or "external" according to +dnl - OUTFILE: One of "dataset", "active", or "external" according to dnl where AGGREGATE's output should be directed. -dnl +dnl dnl - SORT: Either "presorted" or "unsorted" according to whether dnl AGGREGATE should received presorted input. dnl @@ -33,11 +49,12 @@ m4_define([CHECK_AGGREGATE], [ [DATA LIST NOTABLE FILE='aggregate.data' /G N 1-2 S 3(a) W 4. WEIGHT BY w. MISSING VALUES n(4) s('4'). +m4_if([$1], [dataset], [DATASET DECLARE aggregate.]) m4_if([$2], [presorted], [SORT CASES BY g.]) AGGREGATE dnl m4_if([$1], [active], [OUTFILE=*], [$1], [external], [OUTFILE='aggregate.sys'], - [outfile=@%:@AGGREGATE]) dnl + [outfile=aggregate]) dnl m4_if([$2], [presorted], [/PRESORTED]) dnl m4_if([$3], [columnwise], [/MISSING=COLUMNWISE]) /DOCUMENT @@ -119,7 +136,7 @@ m4_if([$3], [columnwise], [/MISSING=COLUMNWISE]) /NSUM = sum(n) /NSUMI = sum.(n). m4_if([$1], [external], [GET FILE='aggregate.sys'.], - [$1], [scratch], [GET FILE=@%:@AGGREGATE.]) + [$1], [dataset], [DATASET ACTIVATE aggregate.]) LIST. ]) AT_CHECK([pspp -O format=csv aggregate.sps], [0], [stdout]) @@ -157,10 +174,10 @@ G,N,NI,NU,NUI,NFGT2,NFGT2I,SFGT2,SFGT2I,NFIN23,NFIN23I,SFIN23,SFIN23I,NFLT2,NFLT ])]) AT_CLEANUP]) -CHECK_AGGREGATE([scratch], [presorted], [itemwise]) -CHECK_AGGREGATE([scratch], [presorted], [columnwise]) -CHECK_AGGREGATE([scratch], [unsorted], [itemwise]) -CHECK_AGGREGATE([scratch], [unsorted], [columnwise]) +CHECK_AGGREGATE([dataset], [presorted], [itemwise]) +CHECK_AGGREGATE([dataset], [presorted], [columnwise]) +CHECK_AGGREGATE([dataset], [unsorted], [itemwise]) +CHECK_AGGREGATE([dataset], [unsorted], [columnwise]) CHECK_AGGREGATE([active], [presorted], [itemwise]) CHECK_AGGREGATE([active], [presorted], [columnwise]) CHECK_AGGREGATE([active], [unsorted], [itemwise]) @@ -171,7 +188,7 @@ CHECK_AGGREGATE([external], [unsorted], [itemwise]) CHECK_AGGREGATE([external], [unsorted], [columnwise]) AT_SETUP([AGGREGATE crash with MAX function]) -AT_DATA([aggregate.sps], +AT_DATA([aggregate.sps], [DATA LIST LIST /X (F8.2) Y (a25). BEGIN DATA. @@ -191,8 +208,8 @@ Y,A25 Table: Data List X,Y -87.34,bar @&t@ -87.50,foo @&t@ +87.34,bar +87.50,foo ]) AT_CLEANUP @@ -210,3 +227,79 @@ AGGREGATE /BREAK=x . ]) AT_CHECK([pspp -O format=csv aggregate.sps], [1], [ignore], []) AT_CLEANUP + + +AT_SETUP([AGGREGATE mode=addvariables]) +AT_DATA([addvariables.sps], + [data list notable list /x * cn * y *. +begin data. +1 1 2 +3 2 3 +3 3 4 +5 4 6 +7 5 8 +7 6 9 +7 7 20 +9 8 11 +end data. + +aggregate outfile=* mode=addvariables + /break = x + /sum = sum(y) + /mean = mean (y) + /median = median (y). + +list. +]) + +AT_CHECK([pspp -O format=csv addvariables.sps], [0], + [Table: Data List +x,cn,y,sum,mean,median +1.00,1.00,2.00,2.00,2.00,2.00 +3.00,2.00,3.00,7.00,3.50,3.50 +3.00,3.00,4.00,7.00,3.50,3.50 +5.00,4.00,6.00,6.00,6.00,6.00 +7.00,5.00,8.00,37.00,12.33,9.00 +7.00,6.00,9.00,37.00,12.33,9.00 +7.00,7.00,20.00,37.00,12.33,9.00 +9.00,8.00,11.00,11.00,11.00,11.00 +]) + +AT_CLEANUP + + +AT_SETUP([AGGREGATE buggy duplicate variables]) +dnl Test for a bug which crashed when duplicated +dnl variables were attempted. +AT_DATA([dup-variables.sps], + [DATA LIST NOTABLE LIST /x * . +begin data +1 +1 +1 +1 +2 +2 +2 +3 +3 +3 +3 +3 +3 +end data. + +AGGREGATE OUTFILE=* MODE=ADDVARIABLES + /BREAK= x + /N_BREAK = N. + +AGGREGATE OUTFILE=* MODE=ADDVARIABLES + /BREAK= x + /N_BREAK = N. +]) + +AT_CHECK([pspp -O format=csv dup-variables.sps], [1], +["dup-variables.sps:24: error: AGGREGATE: Variable name N_BREAK is not unique within the aggregate file dictionary, which contains the aggregate variables and the break variables." +]) + +AT_CLEANUP