3 # This program tests the RANK command.
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
8 # ensure that top_srcdir and top_builddir are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
25 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
26 echo "NOT cleaning $TEMPDIR"
62 # Some tests for proper behaviour in the face of invalid input.
63 activity="create file 1"
65 DATA LIST LIST NOTABLE /x * a (a2).
81 if [ $? -ne 0 ] ; then no_result ; fi
83 # Check that it properly handles failed transformations.
84 activity="run program 1"
85 $SUPERVISOR $PSPP --testing-mode -e $TEMPDIR/err $TESTFILE
86 if [ $? -ne 1 ] ; then fail ; fi
89 perl -pi -e 's/^\s*$//g' $TEMPDIR/err
90 diff -b $TEMPDIR/err - <<EOF
91 $TEMPDIR/rank.sh.sps:14: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
93 if [ $? -ne 0 ] ; then fail ; fi
96 #Now for some general error conditions.
97 activity="create file 2"
99 DATA LIST LIST NOTABLE /x * a (a2).
110 * invalid NTILES (no parameter)
115 * invalid NTILES (not an integer)
121 * destination variable already exists
126 * Too many variables in INTO
128 /RANK INTO foo bar wiz.
130 if [ $? -ne 0 ] ; then no_result ; fi
133 activity="run program (syntax errors)"
134 $SUPERVISOR $PSPP --testing-mode -e $TEMPDIR/errs $TESTFILE
135 if [ $? -ne 1 ] ; then fail ; fi
137 activity="compare errors"
138 perl -pi -e 's/^\s*$//g' $TEMPDIR/errs
139 diff -b $TEMPDIR/errs - << EOF
140 $TEMPDIR/rank.sh.sps:15: error: RANK: Syntax error expecting \`(' at end of command.
141 $TEMPDIR/rank.sh.sps:19: error: RANK: Syntax error expecting integer at \`d'.
142 $TEMPDIR/rank.sh.sps:25: error: RANK: Variable x already exists.
143 $TEMPDIR/rank.sh.sps:30: error: RANK: Too many variables in INTO clause.
145 if [ $? -ne 0 ] ; then fail ; fi
147 # Now some real tests.
149 activity="create file 3"
150 cat > $TESTFILE <<EOF
151 DATA LIST LIST NOTABLE /x (f8).
162 ECHO 'Simple example using defaults'.
169 DATA LIST LIST NOTABLE /a * b *.
196 ECHO 'Test variable name fallback'.
199 DATA LIST LIST NOTABLE /foo * rfoo * ran003 *.
220 DATA LIST LIST NOTABLE /a * b *.
247 DATA LIST LIST NOTABLE /a * g1 g2 *.
294 ECHO 'fractional ranks ( including small ones for special case of SAVAGE ranks)'
296 DATA LIST LIST NOTABLE /a * w * .
319 ECHO 'test all the ties cases with low caseweight values'.
322 DATA LIST LIST NOTABLE /x * w *.
358 if [ $? -ne 0 ] ; then no_result ; fi
361 activity="run program 3"
362 $SUPERVISOR $PSPP --testing-mode $TESTFILE
363 if [ $? -ne 0 ] ; then no_result ; fi
366 activity="compare output 3"
367 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
368 diff -b $TEMPDIR/pspp.list - <<EOF
369 Simple example using defaults
370 Variables Created By RANK
381 Variables Created By RANK
384 a into RFR001(RFRACTION of a)
385 b into RFR002(RFRACTION of b)
389 +--------+-------------------------------------------+--------+
390 |Variable|Description |Position|
391 #========#===========================================#========#
392 |a |Format: F8.2 | 1|
393 | |Measure: Scale | |
394 | |Display Alignment: Right | |
395 | |Display Width: 8 | |
396 +--------+-------------------------------------------+--------+
397 |b |Format: F8.2 | 2|
398 | |Measure: Scale | |
399 | |Display Alignment: Right | |
400 | |Display Width: 8 | |
401 +--------+-------------------------------------------+--------+
404 | |Measure: Scale | |
405 | |Display Alignment: Right | |
406 | |Display Width: 8 | |
407 +--------+-------------------------------------------+--------+
410 | |Measure: Scale | |
411 | |Display Alignment: Right | |
412 | |Display Width: 8 | |
413 +--------+-------------------------------------------+--------+
416 | |Measure: Scale | |
417 | |Display Alignment: Right | |
418 | |Display Width: 8 | |
419 +--------+-------------------------------------------+--------+
420 |RFR001 |RFRACTION of a | 6|
422 | |Measure: Scale | |
423 | |Display Alignment: Right | |
424 | |Display Width: 8 | |
425 +--------+-------------------------------------------+--------+
426 |RFR002 |RFRACTION of b | 7|
428 | |Measure: Scale | |
429 | |Display Alignment: Right | |
430 | |Display Width: 8 | |
431 +--------+-------------------------------------------+--------+
434 | |Measure: Scale | |
435 | |Display Alignment: Right | |
436 | |Display Width: 8 | |
437 +--------+-------------------------------------------+--------+
438 a b count Ra Rb RFR001 RFR002 Nb
439 -------- -------- ------ --------- --------- ------ ------ ------
440 .00 24.00 10 10.000 8.000 1.0000 .8889 9
441 1.00 32.00 10 9.000 4.000 .9000 .4444 9
442 2.00 31.00 10 8.000 5.000 .8000 .5556 9
443 2.00 32.00 10 8.000 4.000 .8000 .4444 9
444 4.00 30.00 10 6.000 6.000 .6000 .6667 9
445 5.00 29.00 10 5.000 7.000 .5000 .7778 9
446 6.00 1.00 10 4.000 9.000 .4000 1.0000 9
447 7.00 43.00 10 3.000 2.000 .3000 .2222 9
448 8.00 . 10 2.000 . .2000 . .
449 9.00 45.00 10 1.000 1.000 .1000 .1111 9
450 Test variable name fallback
451 Variables Created By RANK
452 foo into RAN001(RANK of foo)
454 +--------+-------------------------------------------+--------+
455 |Variable|Description |Position|
456 #========#===========================================#========#
457 |foo |Format: F8.2 | 1|
458 | |Measure: Scale | |
459 | |Display Alignment: Right | |
460 | |Display Width: 8 | |
461 +--------+-------------------------------------------+--------+
462 |rfoo |Format: F8.2 | 2|
463 | |Measure: Scale | |
464 | |Display Alignment: Right | |
465 | |Display Width: 8 | |
466 +--------+-------------------------------------------+--------+
467 |ran003 |Format: F8.2 | 3|
468 | |Measure: Scale | |
469 | |Display Alignment: Right | |
470 | |Display Width: 8 | |
471 +--------+-------------------------------------------+--------+
472 |RAN001 |RANK of foo | 4|
474 | |Measure: Scale | |
475 | |Display Alignment: Right | |
476 | |Display Width: 8 | |
477 +--------+-------------------------------------------+--------+
478 Variables Created By RANK
479 a into Sa(SAVAGE of a)
480 a into Pa(PERCENT of a)
481 a into PRO001(PROPORTION of a using BLOM)
482 a into Na(NTILES of a)
483 a into NOR001(NORMAL of a using BLOM)
484 a b Sa Pa PRO001 Na NOR001
485 -------- -------- -------- ------ ------ --- ------
486 .00 24.00 -.9000 10.00 .0610 1 -1.547
487 1.00 32.00 -.7889 20.00 .1585 1 -1.000
488 2.00 31.00 -.5925 30.00 .2561 2 -.6554
489 2.00 32.00 -.5925 30.00 .2561 2 -.6554
490 4.00 30.00 -.3544 40.00 .3537 2 -.3755
491 5.00 29.00 -.1544 50.00 .4512 2 -.1226
492 6.00 1.00 .0956 60.00 .5488 3 .1226
493 7.00 43.00 .4290 70.00 .6463 3 .3755
494 8.00 8.00 .9290 80.00 .7439 3 .6554
495 9.00 45.00 1.9290 90.00 .8415 4 1.0005
496 Variables Created By RANK
497 a into Ra(RANK of a BY g2 g1)
498 a into Na(NORMAL of a using RANKIT BY g2 g1)
499 Variables Created By RANK
500 a into RAN001(RANK of a BY g2)
501 a into NOR001(NORMAL of a using RANKIT BY g2)
502 a g1 g2 Ra Na RAN001 NOR001
503 -------- -------- -------- --------- ------ --------- ------
504 2.00 1.00 2.00 8.000 .9674 4.000 .5244
505 2.00 1.00 2.00 8.000 .9674 4.000 .5244
506 3.00 1.00 2.00 7.000 .5895 3.000 .0000
507 4.00 1.00 2.00 6.000 .2822 2.000 -.5244
508 5.00 1.00 2.00 5.000 .0000 1.000 -1.282
509 1.00 .00 2.00 8.000 1.5341 8.000 1.5341
510 2.00 .00 2.00 7.000 .8871 7.000 .8871
511 3.00 .00 2.00 6.000 .4888 6.000 .4888
512 4.00 .00 2.00 5.000 .1573 5.000 .1573
513 5.00 .00 2.00 4.000 -.1573 4.000 -.1573
514 6.00 .00 2.00 3.000 -.4888 3.000 -.4888
515 7.00 .00 2.00 2.000 -.8871 2.000 -.8871
516 8.00 .00 2.00 1.000 -1.534 1.000 -1.534
517 6.00 1.00 2.00 4.000 -.2822 4.000 1.1503
518 7.00 1.00 2.00 2.000 -.9674 2.000 -.3186
519 7.00 1.00 2.00 2.000 -.9674 2.000 -.3186
520 8.00 1.00 2.00 1.000 -1.593 1.000 -1.150
521 9.00 1.00 1.00 1.000 .0000 1.000 .0000
522 fractional ranks ( including small ones for special case of SAVAGE ranks)
523 Variables Created By RANK
524 a into Pa(PROPORTION of a using TUKEY)
525 a into Sa(SAVAGE of a)
527 -------- -------- ------ --------
528 1.00 1.50 .1285 -.8016
529 2.00 .20 .1776 -.6905
530 3.00 .10 .1986 -.6905
531 4.00 1.00 .3458 -.5305
532 5.00 1.00 .4860 -.2905
533 6.00 1.00 .6262 .0262
534 7.00 1.00 .7664 .4929
535 8.00 1.00 .9065 1.3929
536 test all the ties cases with low caseweight values
537 Variables Created By RANK
539 Variables Created By RANK
541 Variables Created By RANK
543 Variables Created By RANK
544 x into Nx(NORMAL of x using VW)
546 -------- -------- --------- --------- --------- ------
547 1.00 .10 .000 .100 1.000 -1.938
548 2.00 .10 .100 .200 2.000 -1.412
549 3.00 .10 .200 .300 3.000 -1.119
550 4.00 .20 .300 .500 4.000 -.8046
551 5.00 .10 .500 .600 5.000 -.5549
552 6.00 .10 .600 .700 6.000 -.4067
553 7.00 .10 .700 .800 7.000 -.2670
554 8.00 .10 .800 .900 8.000 -.1323
556 if [ $? -ne 0 ] ; then fail ; fi
560 # A test to make sure that variable name creation is really robust
561 activity="create file 4"
562 cat > $TESTFILE <<EOF
563 DATA LIST LIST notable /x * rx * ran001 TO ran999.
576 DELETE VAR ran001 TO ran999.
581 if [ $? -ne 0 ] ; then no_result ; fi
583 activity="run program 4"
584 $SUPERVISOR $PSPP --testing-mode -e /dev/null $TESTFILE
585 if [ $? -ne 0 ] ; then fail ; fi
588 activity="compare output 4"
589 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
590 diff -b $TEMPDIR/pspp.list - << EOF
591 $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.
592 $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.
593 $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.
594 $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.
595 $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.
596 $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.
597 $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.
598 Variables Created By RANK
599 x into RNKRA01(RANK of x)
601 -------- -------- ---------
610 if [ $? -ne 0 ] ; then fail ; fi