Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / rank.sh
index d98c8e2211c67b0316334b2973f84ed9e726f00f..bc208af8a73f9db5736779c8d16e6ce22f3e5675 100755 (executable)
@@ -136,7 +136,7 @@ if [ $? -ne 1 ] ; then fail ; fi
 
 activity="compare errors"
 perl -pi -e 's/^\s*$//g' $TEMPDIR/errs
-diff  -b $TEMPDIR/errs - << EOF
+diff -b $TEMPDIR/errs - << EOF
 $TEMPDIR/rank.sh.sps:15: error: RANK: Syntax error expecting \`(' at end of command.
 $TEMPDIR/rank.sh.sps:19: error: RANK: Syntax error expecting integer at \`d'.
 $TEMPDIR/rank.sh.sps:25: error: RANK: Variable x already exists.
@@ -364,194 +364,242 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="compare output 3"
-perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
-diff  -b $TEMPDIR/pspp.list - <<EOF
+diff -c $TEMPDIR/pspp.csv - <<EOF
 Simple example using defaults
+
 Variables Created By RANK
+
+
+
 x into Rx(RANK of x)
-       x        Rx
--------- ---------
-      -1     1.000 
-       0     2.000 
-       1     3.000 
-       2     4.500 
-       2     4.500 
-       4     6.000 
-       5     7.000 
+
+Table: Data List
+x,Rx
+-1,1.000
+0,2.000
+1,3.000
+2,4.500
+2,4.500
+4,6.000
+5,7.000
+
 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)
-1.1 DISPLAY.  
-+--------+-------------------------------------------+--------+
-|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                           |        |
-+--------+-------------------------------------------+--------+
-       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 
+
+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: 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
+
 Test variable name fallback
+
 Variables Created By RANK
+
+
+
 foo into RAN001(RANK of foo)
-2.1 DISPLAY.  
-+--------+-------------------------------------------+--------+
-|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                           |        |
-+--------+-------------------------------------------+--------+
+
+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,,
+
 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)
-       a        b       Sa     Pa PRO001  Na NOR001
--------- -------- -------- ------ ------ --- ------
-     .00    24.00   -.9000  10.00  .0610   1 -1.547 
-    1.00    32.00   -.7889  20.00  .1585   1 -1.000 
-    2.00    31.00   -.5925  30.00  .2561   2 -.6554 
-    2.00    32.00   -.5925  30.00  .2561   2 -.6554 
-    4.00    30.00   -.3544  40.00  .3537   2 -.3755 
-    5.00    29.00   -.1544  50.00  .4512   2 -.1226 
-    6.00     1.00    .0956  60.00  .5488   3  .1226 
-    7.00    43.00    .4290  70.00  .6463   3  .3755 
-    8.00     8.00    .9290  80.00  .7439   3  .6554 
-    9.00    45.00   1.9290  90.00  .8415   4 1.0005 
+
+Table: Data List
+a,b,Sa,Pa,PRO001,Na,NOR001
+.00,24.00,-.9000,10.00,.0610,1,-1.547
+1.00,32.00,-.7889,20.00,.1585,1,-1.000
+2.00,31.00,-.5925,30.00,.2561,2,-.6554
+2.00,32.00,-.5925,30.00,.2561,2,-.6554
+4.00,30.00,-.3544,40.00,.3537,2,-.3755
+5.00,29.00,-.1544,50.00,.4512,2,-.1226
+6.00,1.00,.0956,60.00,.5488,3,.1226
+7.00,43.00,.4290,70.00,.6463,3,.3755
+8.00,8.00,.9290,80.00,.7439,3,.6554
+9.00,45.00,1.9290,90.00,.8415,4,1.0005
+
 Variables Created By RANK
+
+
+
 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)
-       a       g1       g2        Ra     Na    RAN001 NOR001 
--------- -------- -------- --------- ------ --------- ------ 
-    2.00     1.00     2.00     8.000  .9674     4.000  .5244  
-    2.00     1.00     2.00     8.000  .9674     4.000  .5244  
-    3.00     1.00     2.00     7.000  .5895     3.000  .0000  
-    4.00     1.00     2.00     6.000  .2822     2.000 -.5244  
-    5.00     1.00     2.00     5.000  .0000     1.000 -1.282  
-    1.00      .00     2.00     8.000 1.5341     8.000 1.5341  
-    2.00      .00     2.00     7.000  .8871     7.000  .8871  
-    3.00      .00     2.00     6.000  .4888     6.000  .4888  
-    4.00      .00     2.00     5.000  .1573     5.000  .1573  
-    5.00      .00     2.00     4.000 -.1573     4.000 -.1573  
-    6.00      .00     2.00     3.000 -.4888     3.000 -.4888  
-    7.00      .00     2.00     2.000 -.8871     2.000 -.8871  
-    8.00      .00     2.00     1.000 -1.534     1.000 -1.534  
-    6.00     1.00     2.00     4.000 -.2822     4.000 1.1503  
-    7.00     1.00     2.00     2.000 -.9674     2.000 -.3186  
-    7.00     1.00     2.00     2.000 -.9674     2.000 -.3186  
-    8.00     1.00     2.00     1.000 -1.593     1.000 -1.150  
-    9.00     1.00     1.00     1.000  .0000     1.000  .0000  
+
+Table: Data List
+a,g1,g2,Ra,Na,RAN001,NOR001
+2.00,1.00,2.00,8.000,.9674,4.000,.5244
+2.00,1.00,2.00,8.000,.9674,4.000,.5244
+3.00,1.00,2.00,7.000,.5895,3.000,.0000
+4.00,1.00,2.00,6.000,.2822,2.000,-.5244
+5.00,1.00,2.00,5.000,.0000,1.000,-1.282
+1.00,.00,2.00,8.000,1.5341,8.000,1.5341
+2.00,.00,2.00,7.000,.8871,7.000,.8871
+3.00,.00,2.00,6.000,.4888,6.000,.4888
+4.00,.00,2.00,5.000,.1573,5.000,.1573
+5.00,.00,2.00,4.000,-.1573,4.000,-.1573
+6.00,.00,2.00,3.000,-.4888,3.000,-.4888
+7.00,.00,2.00,2.000,-.8871,2.000,-.8871
+8.00,.00,2.00,1.000,-1.534,1.000,-1.534
+6.00,1.00,2.00,4.000,-.2822,4.000,1.1503
+7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
+7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
+8.00,1.00,2.00,1.000,-1.593,1.000,-1.150
+9.00,1.00,1.00,1.000,.0000,1.000,.0000
+
 fractional ranks ( including small ones for special case of SAVAGE ranks)
+
 Variables Created By RANK
+
+
+
 a into Pa(PROPORTION of a using TUKEY)
+
 a into Sa(SAVAGE of a)
-       a        w     Pa       Sa
--------- -------- ------ --------
-    1.00     1.50  .1285   -.8016 
-    2.00      .20  .1776   -.6905 
-    3.00      .10  .1986   -.6905 
-    4.00     1.00  .3458   -.5305 
-    5.00     1.00  .4860   -.2905 
-    6.00     1.00  .6262    .0262 
-    7.00     1.00  .7664    .4929 
-    8.00     1.00  .9065   1.3929 
+
+Table: Data List
+a,w,Pa,Sa
+1.00,1.50,.1285,-.8016
+2.00,.20,.1776,-.6905
+3.00,.10,.1986,-.6905
+4.00,1.00,.3458,-.5305
+5.00,1.00,.4860,-.2905
+6.00,1.00,.6262,.0262
+7.00,1.00,.7664,.4929
+8.00,1.00,.9065,1.3929
+
 test all the ties cases with low caseweight values
+
 Variables Created By RANK
+
+
+
 x into xl(RANK of x)
+
 Variables Created By RANK
+
+
+
 x into xh(RANK of x)
+
 Variables Created By RANK
+
+
+
 x into xc(RANK of x)
+
 Variables Created By RANK
+
+
+
 x into Nx(NORMAL of x using VW)
-       x        w        xl        xh        xc     Nx
--------- -------- --------- --------- --------- ------
-    1.00      .10      .000      .100     1.000 -1.938 
-    2.00      .10      .100      .200     2.000 -1.412 
-    3.00      .10      .200      .300     3.000 -1.119 
-    4.00      .20      .300      .500     4.000 -.8046 
-    5.00      .10      .500      .600     5.000 -.5549 
-    6.00      .10      .600      .700     6.000 -.4067 
-    7.00      .10      .700      .800     7.000 -.2670 
-    8.00      .10      .800      .900     8.000 -.1323 
+
+Table: Data List
+x,w,xl,xh,xc,Nx
+1.00,.10,.000,.100,1.000,-1.938
+2.00,.10,.100,.200,2.000,-1.412
+3.00,.10,.200,.300,3.000,-1.119
+4.00,.20,.300,.500,4.000,-.8046
+5.00,.10,.500,.600,5.000,-.5549
+6.00,.10,.600,.700,6.000,-.4067
+7.00,.10,.700,.800,7.000,-.2670
+8.00,.10,.800,.900,8.000,-.1323
 EOF
 if [ $? -ne 0 ] ; then fail ; fi
 
@@ -586,26 +634,36 @@ if [ $? -ne 0 ] ; then fail ; fi
 
 
 activity="compare output 4"
-perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
-diff  -b $TEMPDIR/pspp.list - << EOF
-$TEMPDIR/rank.sh.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.
-$TEMPDIR/rank.sh.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.
-$TEMPDIR/rank.sh.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.
-$TEMPDIR/rank.sh.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.
-$TEMPDIR/rank.sh.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.
-$TEMPDIR/rank.sh.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.
-$TEMPDIR/rank.sh.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.
+diff -c $TEMPDIR/pspp.csv - << EOF
+"$TEMPDIR/rank.sh.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."
+
+"$TEMPDIR/rank.sh.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."
+
+"$TEMPDIR/rank.sh.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."
+
+"$TEMPDIR/rank.sh.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."
+
+"$TEMPDIR/rank.sh.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."
+
+"$TEMPDIR/rank.sh.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."
+
+"$TEMPDIR/rank.sh.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."
+
 Variables Created By RANK
+
+
+
 x into RNKRA01(RANK of x)
-       x       rx   RNKRA01
--------- -------- ---------
-    1.00      .       1.000 
-    2.00      .       2.000 
-    3.00      .       3.000 
-    4.00      .       4.000 
-    5.00      .       5.000 
-    6.00      .       6.000 
-    7.00      .       7.000 
+
+Table: Data List
+x,rx,RNKRA01
+1.00,.  ,1.000
+2.00,.  ,2.000
+3.00,.  ,3.000
+4.00,.  ,4.000
+5.00,.  ,5.000
+6.00,.  ,6.000
+7.00,.  ,7.000
 EOF
 if [ $? -ne 0 ] ; then fail ; fi