X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Frank.at;h=bd3f8becb478495b37e66574fe2db0db7f2d10c7;hb=0891406f7c1039af8c769b8069691246566fd894;hp=ac44189c25b3588446ffd9325c48d16b72ee69f1;hpb=973fb7a1cd984715bc5e1f46a8b8922e5a5f6fd7;p=pspp diff --git a/tests/language/stats/rank.at b/tests/language/stats/rank.at index ac44189c25..bd3f8becb4 100644 --- a/tests/language/stats/rank.at +++ b/tests/language/stats/rank.at @@ -1,3 +1,19 @@ +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([RANK]) AT_SETUP([RANK simple case with defaults]) @@ -5,12 +21,12 @@ AT_DATA([rank.sps], [dnl DATA LIST LIST NOTABLE /x (f8). BEGIN DATA. -1 -0 -1 -2 -2 -4 -5 +0 +1 +2 +2 +4 +5 END DATA. RANK x. @@ -19,11 +35,9 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - - - -x into Rx(RANK of x) +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,Rx,RANK Table: Data List x,Rx @@ -37,6 +51,36 @@ x,Rx ]) AT_CLEANUP +# This checks for regression against a crash reported as bug #38482 +# that occurred when multiple variables were specified without any +# rank specifications. +AT_SETUP([RANK multiple variables with defaults]) +AT_DATA([rank.sps], [dnl +DATA LIST LIST NOTABLE /x * y * z *. +BEGIN DATA. + 1.00 2.00 3.00 + 4.00 5.00 6.00 +END DATA. + +RANK ALL. + +LIST. +]) +AT_CHECK([pspp -o pspp.csv rank.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,Rx,RANK +y,Ry,RANK +z,Rz,RANK + +Table: Data List +x,y,z,Rx,Ry,Rz +1.00,2.00,3.00,1.000,1.000,1.000 +4.00,5.00,6.00,2.000,2.000,2.000 +]) +AT_CLEANUP + AT_SETUP([RANK with RANK, RFRACTION, N]) AT_DATA([rank.sps], [dnl DATA LIST LIST NOTABLE /a * b *. @@ -54,7 +98,7 @@ BEGIN DATA. END DATA. RANK a b (D) - /PRINT=YES + /PRINT=YES /RANK /TIES=HIGH /RFRACTION @@ -67,74 +111,38 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - - - -a into Ra(RANK of a) - -b into Rb(RANK of b) - -a into RFR001(RFRACTION of a) - -b into RFR002(RFRACTION of b) - -a into count(N of a) - -b into Nb(N of b) - -Variable,Description,,Position -a,Format: F8.2,,1 -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -b,Format: F8.2,,2 -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -count,N of a,,3 -,Format: F6.0,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -Ra,RANK of a,,4 -,Format: F9.3,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -Rb,RANK of b,,5 -,Format: F9.3,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -RFR001,RFRACTION of a,,6 -,Format: F6.4,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -RFR002,RFRACTION of b,,7 -,Format: F6.4,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -Nb,N of b,,8 -,Format: F6.0,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, +Table: Variables Created by RANK +Existing Variable,New Variable,Function +a,Ra,RANK +b,Rb,RANK +a,RFR001,RFRACTION +b,RFR002,RFRACTION +a,count,N +b,Nb,N + +Table: Variables +Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format +a,1,,Nominal,Input,8,Right,F8.2,F8.2 +b,2,,Nominal,Input,8,Right,F8.2,F8.2 +Ra,3,RANK of a,Ordinal,Input,8,Right,F9.3,F9.3 +RFR001,4,RFRACTION of a,Ordinal,Input,8,Right,F6.4,F6.4 +count,5,N of a,Scale,Input,8,Right,F6.0,F6.0 +Rb,6,RANK of b,Ordinal,Input,8,Right,F9.3,F9.3 +RFR002,7,RFRACTION of b,Ordinal,Input,8,Right,F6.4,F6.4 +Nb,8,N of b,Scale,Input,8,Right,F6.0,F6.0 Table: Data List -a,b,count,Ra,Rb,RFR001,RFR002,Nb -.00,24.00,10,10.000,8.000,1.0000,.8889,9 -1.00,32.00,10,9.000,4.000,.9000,.4444,9 -2.00,31.00,10,8.000,5.000,.8000,.5556,9 -2.00,32.00,10,8.000,4.000,.8000,.4444,9 -4.00,30.00,10,6.000,6.000,.6000,.6667,9 -5.00,29.00,10,5.000,7.000,.5000,.7778,9 -6.00,1.00,10,4.000,9.000,.4000,1.0000,9 -7.00,43.00,10,3.000,2.000,.3000,.2222,9 -8.00,. ,10,2.000,. ,.2000,. ,. -9.00,45.00,10,1.000,1.000,.1000,.1111,9 +a,b,Ra,RFR001,count,Rb,RFR002,Nb +.00,24.00,10.000,1.0000,10,8.000,.8889,9 +1.00,32.00,9.000,.9000,10,4.000,.4444,9 +2.00,31.00,8.000,.8000,10,5.000,.5556,9 +2.00,32.00,8.000,.8000,10,4.000,.4444,9 +4.00,30.00,6.000,.6000,10,6.000,.6667,9 +5.00,29.00,5.000,.5000,10,7.000,.7778,9 +6.00,1.00,4.000,.4000,10,9.000,1.0000,9 +7.00,43.00,3.000,.3000,10,2.000,.2222,9 +8.00,. ,2.000,.2000,10,. ,. ,. +9.00,45.00,1.000,.1000,10,1.000,.1111,9 ]) AT_CLEANUP @@ -150,7 +158,7 @@ BEGIN DATA. 5 29 6 1 7 43 -8 8 +8 8 9 45 END DATA. @@ -168,19 +176,13 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - - - -a into Sa(SAVAGE of a) - -a into Pa(PERCENT of a) - -a into PRO001(PROPORTION of a using BLOM) - -a into Na(NTILES of a) - -a into NOR001(NORMAL of a using BLOM) +Table: Variables Created by RANK +Existing Variable,New Variable,Function,Fraction +a,Sa,SAVAGE, +a,Pa,PERCENT, +a,PRO001,PROPORTION,BLOM +a,Na,NTILES, +a,NOR001,NORMAL,BLOM Table: Data List a,b,Sa,Pa,PRO001,Na,NOR001 @@ -247,21 +249,15 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - +Table: Variables Created by RANK +Existing Variable,New Variable,Function,Fraction,Grouping Variables +a,Ra,RANK,,g2 g1 +a,Na,NORMAL,RANKIT,g2 g1 - -a into Ra(RANK of a BY g2 g1) - -a into Na(NORMAL of a using RANKIT BY g2 g1) - -Variables Created By RANK - - - -a into RAN001(RANK of a BY g2) - -a into NOR001(NORMAL of a using RANKIT BY g2) +Table: Variables Created by RANK +Existing Variable,New Variable,Function,Fraction,Grouping Variables +a,RAN001,RANK,,g2 +a,NOR001,NORMAL,RANKIT,g2 Table: Data List a,g1,g2,Ra,Na,RAN001,NOR001 @@ -287,7 +283,7 @@ a,g1,g2,Ra,Na,RAN001,NOR001 AT_CLEANUP # Also tests small ranks for special case of SAVAGE ranks. -AT_SETUP([RANK with fractional ranks]) +AT_SETUP([RANK with fractional ranks]) AT_DATA([rank.sps], [dnl DATA LIST LIST NOTABLE /a * w * . BEGIN DATA. @@ -303,7 +299,7 @@ END DATA. WEIGHT BY w. -RANK a +RANK a /FRACTION=TUKEY /PROPORTION /SAVAGE @@ -313,13 +309,10 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - - - -a into Pa(PROPORTION of a using TUKEY) - -a into Sa(SAVAGE of a) +Table: Variables Created by RANK +Existing Variable,New Variable,Function,Fraction +a,Pa,PROPORTION,TUKEY +a,Sa,SAVAGE, Table: Data List a,w,Pa,Sa @@ -374,29 +367,21 @@ LIST. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - - - -x into xl(RANK of x) - -Variables Created By RANK - - - -x into xh(RANK of x) - -Variables Created By RANK +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,xl,RANK +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,xh,RANK +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,xc,RANK -x into xc(RANK of x) - -Variables Created By RANK - - - -x into Nx(NORMAL of x using VW) +Table: Variables Created by RANK +Existing Variable,New Variable,Function,Fraction +x,Nx,NORMAL,VW Table: Data List x,w,xl,xh,xc,Nx @@ -411,6 +396,58 @@ x,w,xl,xh,xc,Nx ]) AT_CLEANUP +AT_SETUP([RANK and TEMPORARY]) +AT_DATA([rank.sps], [dnl +DATA LIST LIST NOTABLE /age (f2) gender (a1). +BEGIN DATA. +44 m +32 f +43 m +49 m +33 f +35 f +29 f +50 m +42 m +33 f +48 m +END DATA. + +TEMPORARY. +SELECT IF gender = 'm'. +RANK age /RANK INTO Rm. + +TEMPORARY. +SELECT IF gender = 'f'. +RANK age /RANK INTO Rf. + +LIST. +]) +AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl +Table: Variables Created by RANK +Existing Variable,New Variable,Function +age,Rm,RANK + +Table: Variables Created by RANK +Existing Variable,New Variable,Function +age,Rf,RANK + +Table: Data List +age,gender,Rm,Rf +44,m,3.000,. @&t@ +32,f,. ,2.000 +43,m,2.000,. @&t@ +49,m,5.000,. @&t@ +33,f,. ,3.500 +35,f,. ,5.000 +29,f,. ,1.000 +50,m,6.000,. @&t@ +42,m,1.000,. @&t@ +33,f,. ,3.500 +48,m,4.000,. @&t@ +]) +AT_CLEANUP + AT_SETUP([RANK variable name fallback]) AT_DATA([rank.sps], [dnl DATA LIST LIST NOTABLE /foo * rfoo * ran003 *. @@ -434,30 +471,16 @@ DISPLAY DICTIONARY. ]) AT_CHECK([pspp -o pspp.csv rank.sps]) AT_CHECK([cat pspp.csv], [0], [dnl -Variables Created By RANK - - - -foo into RAN001(RANK of foo) - -Variable,Description,,Position -foo,Format: F8.2,,1 -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -rfoo,Format: F8.2,,2 -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -ran003,Format: F8.2,,3 -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, -RAN001,RANK of foo,,4 -,Format: F9.3,, -,Measure: Scale,, -,Display Alignment: Right,, -,Display Width: 8,, +Table: Variables Created by RANK +Existing Variable,New Variable,Function +foo,RAN001,RANK + +Table: Variables +Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format +foo,1,,Nominal,Input,8,Right,F8.2,F8.2 +rfoo,2,,Nominal,Input,8,Right,F8.2,F8.2 +ran003,3,,Nominal,Input,8,Right,F8.2,F8.2 +RAN001,4,RANK of foo,Ordinal,Input,8,Right,F9.3,F9.3 ]) AT_CLEANUP @@ -481,25 +504,23 @@ DELETE VAR ran001 TO ran999. LIST. ]) AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl -"rank.sps:3: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." - -"rank.sps:4: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." +"rank.sps:3: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." -"rank.sps:5: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." +"rank.sps:4: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." -"rank.sps:6: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." +"rank.sps:5: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." -"rank.sps:7: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." +"rank.sps:6: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." -"rank.sps:8: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." +"rank.sps:7: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." -"rank.sps:9: warning: BEGIN DATA: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." +"rank.sps:8: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." -Variables Created By RANK +"rank.sps:9: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate." - - -x into RNKRA01(RANK of x) +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,RNKRA01,RANK Table: Data List x,rx,RNKRA01 @@ -532,13 +553,11 @@ DEBUG XFORM FAIL. RANK x. ]) AT_CHECK([pspp -O format=csv --testing-mode rank.sps], [1], [dnl -Variables Created By RANK - - - -x into Rx(RANK of x) +Table: Variables Created by RANK +Existing Variable,New Variable,Function +x,Rx,RANK -rank.sps:14: error: Stopping syntax file processing here to avoid a cascade of dependent command failures. +rank.sps:14: error: RANK: DEBUG XFORM FAIL transformation executed ]) AT_CLEANUP @@ -556,29 +575,29 @@ BEGIN DATA. END DATA. * invalid NTILES (no parameter) -RANK x +RANK x /NTILES . * invalid NTILES (not an integer) -RANK x +RANK x /NTILES(d) . * destination variable already exists -RANK x +RANK x /RANK INTO x. * Too many variables in INTO -RANK x +RANK x /RANK INTO foo bar wiz. ]) AT_CHECK([pspp -O format=csv rank.sps], [1], [dnl -rank.sps:15: error: RANK: Syntax error at end of command: expecting `@{:@'. +rank.sps:15.1: error: RANK: Syntax error at end of command: expecting `@{:@'. -rank.sps:19: error: RANK: Syntax error at `d': expecting integer. +rank.sps:19.11: error: RANK: Syntax error at `d': Expected positive integer for NTILES. rank.sps:25: error: RANK: Variable x already exists.