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"
61 # Some tests for proper behaviour in the face of invalid input.
62 activity="create file 1"
64 DATA LIST LIST NOTABLE /x * a (a2).
80 if [ $? -ne 0 ] ; then no_result ; fi
82 # Check that it properly handles failed transformations.
83 activity="run program 1"
84 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > $TEMPDIR/err
85 if [ $? -ne 1 ] ; then fail ; fi
88 perl -pi -e 's/^\s*$//g' $TEMPDIR/err
89 diff -b $TEMPDIR/err - <<EOF
90 $TEMPDIR/rank.sh.sps:14: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
92 if [ $? -ne 0 ] ; then fail ; fi
95 #Now for some general error conditions.
96 activity="create file 2"
98 DATA LIST LIST NOTABLE /x * a (a2).
109 * invalid NTILES (no parameter)
114 * invalid NTILES (not an integer)
120 * destination variable already exists
125 * Too many variables in INTO
127 /RANK INTO foo bar wiz.
134 if [ $? -ne 0 ] ; then no_result ; fi
137 activity="run program (syntax errors)"
138 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > $TEMPDIR/errs
139 if [ $? -ne 1 ] ; then fail ; fi
141 activity="compare errors"
142 perl -pi -e 's/^\s*$//g' $TEMPDIR/errs
143 diff -b $TEMPDIR/errs - << EOF
144 $TEMPDIR/rank.sh.sps:15: error: RANK: Syntax error expecting \`(' at end of command.
145 $TEMPDIR/rank.sh.sps:19: error: RANK: Syntax error expecting integer at \`d'.
146 $TEMPDIR/rank.sh.sps:25: error: RANK: Variable x already exists.
147 $TEMPDIR/rank.sh.sps:30: error: RANK: Too many variables in INTO clause.
148 $TEMPDIR/rank.sh.sps:33: warning: RANK: a is not a numeric variable. It will not be included in the variable list.
150 if [ $? -ne 0 ] ; then fail ; fi
152 # Now some real tests.
154 activity="create file 3"
155 cat > $TESTFILE <<EOF
156 DATA LIST LIST NOTABLE /x (f8).
167 ECHO 'Simple example using defaults'.
174 DATA LIST LIST NOTABLE /a * b *.
201 ECHO 'Test variable name fallback'.
204 DATA LIST LIST NOTABLE /foo * rfoo * ran003 *.
225 DATA LIST LIST NOTABLE /a * b *.
252 DATA LIST LIST NOTABLE /a * g1 g2 *.
286 ECHO 'fractional ranks ( including small ones for special case of SAVAGE ranks)'
288 DATA LIST LIST NOTABLE /a * w * .
311 ECHO 'test all the ties cases with low caseweight values'.
314 DATA LIST LIST NOTABLE /x * w *.
350 if [ $? -ne 0 ] ; then no_result ; fi
353 activity="run program 3"
354 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
355 if [ $? -ne 0 ] ; then no_result ; fi
358 activity="compare output 3"
359 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
360 diff -b $TEMPDIR/pspp.list - <<EOF
361 Simple example using defaults
362 Variables Created By RANK
373 Variables Created By RANK
376 a into RFR001(RFRACTION of a)
377 b into RFR002(RFRACTION of b)
381 +--------+-------------------------------------------+--------+
382 |Variable|Description |Position|
383 #========#===========================================#========#
384 |a |Format: F8.2 | 1|
385 +--------+-------------------------------------------+--------+
386 |b |Format: F8.2 | 2|
387 +--------+-------------------------------------------+--------+
390 +--------+-------------------------------------------+--------+
393 +--------+-------------------------------------------+--------+
396 +--------+-------------------------------------------+--------+
397 |RFR001 |RFRACTION of a | 6|
399 +--------+-------------------------------------------+--------+
400 |RFR002 |RFRACTION of b | 7|
402 +--------+-------------------------------------------+--------+
405 +--------+-------------------------------------------+--------+
406 a b count Ra Rb RFR001 RFR002 Nb
407 -------- -------- ------ --------- --------- ------ ------ ------
408 .00 24.00 10 10.000 8.000 1.0000 .8889 9
409 1.00 32.00 10 9.000 4.000 .9000 .4444 9
410 2.00 31.00 10 8.000 5.000 .8000 .5556 9
411 2.00 32.00 10 8.000 4.000 .8000 .4444 9
412 4.00 30.00 10 6.000 6.000 .6000 .6667 9
413 5.00 29.00 10 5.000 7.000 .5000 .7778 9
414 6.00 1.00 10 4.000 9.000 .4000 1.0000 9
415 7.00 43.00 10 3.000 2.000 .3000 .2222 9
416 8.00 . 10 2.000 . .2000 . .
417 9.00 45.00 10 1.000 1.000 .1000 .1111 9
418 Test variable name fallback
419 Variables Created By RANK
420 foo into RAN001(RANK of foo)
422 +--------+-------------------------------------------+--------+
423 |Variable|Description |Position|
424 #========#===========================================#========#
425 |foo |Format: F8.2 | 1|
426 +--------+-------------------------------------------+--------+
427 |rfoo |Format: F8.2 | 2|
428 +--------+-------------------------------------------+--------+
429 |ran003 |Format: F8.2 | 3|
430 +--------+-------------------------------------------+--------+
431 |RAN001 |RANK of foo | 4|
433 +--------+-------------------------------------------+--------+
434 Variables Created By RANK
435 a into Sa(SAVAGE of a)
436 a into Pa(PERCENT of a)
437 a into PRO001(PROPORTION of a using BLOM)
438 a into Na(NTILES of a)
439 a into NOR001(NORMAL of a using BLOM)
440 a b Sa Pa PRO001 Na NOR001
441 -------- -------- -------- ------ ------ --- ------
442 .00 24.00 -.9000 10.00 .0610 1 -1.547
443 1.00 32.00 -.7889 20.00 .1585 1 -1.000
444 2.00 31.00 -.5925 30.00 .2561 2 -.6554
445 2.00 32.00 -.5925 30.00 .2561 2 -.6554
446 4.00 30.00 -.3544 40.00 .3537 2 -.3755
447 5.00 29.00 -.1544 50.00 .4512 2 -.1226
448 6.00 1.00 .0956 60.00 .5488 3 .1226
449 7.00 43.00 .4290 70.00 .6463 3 .3755
450 8.00 8.00 .9290 80.00 .7439 3 .6554
451 9.00 45.00 1.9290 90.00 .8415 4 1.0005
452 Variables Created By RANK
453 a into Ra(RANK of a BY g2 g1)
454 a into Na(NORMAL of a using RANKIT BY g2 g1)
456 -------- -------- -------- --------- ------
457 1.00 .00 2.00 8.000 1.5341
458 2.00 .00 2.00 7.000 .8871
459 3.00 .00 2.00 6.000 .4888
460 4.00 .00 2.00 5.000 .1573
461 5.00 .00 2.00 4.000 -.1573
462 6.00 .00 2.00 3.000 -.4888
463 7.00 .00 2.00 2.000 -.8871
464 8.00 .00 2.00 1.000 -1.534
465 2.00 1.00 2.00 8.000 .9674
466 2.00 1.00 2.00 8.000 .9674
467 3.00 1.00 2.00 7.000 .5895
468 4.00 1.00 2.00 6.000 .2822
469 5.00 1.00 2.00 5.000 .0000
470 6.00 1.00 2.00 4.000 -.2822
471 7.00 1.00 2.00 2.000 -.9674
472 7.00 1.00 2.00 2.000 -.9674
473 8.00 1.00 2.00 1.000 -1.593
474 9.00 1.00 1.00 1.000 .0000
475 fractional ranks ( including small ones for special case of SAVAGE ranks)
476 Variables Created By RANK
477 a into Pa(PROPORTION of a using TUKEY)
478 a into Sa(SAVAGE of a)
480 -------- -------- ------ --------
481 1.00 1.50 .1285 -.8016
482 2.00 .20 .1776 -.6905
483 3.00 .10 .1986 -.6905
484 4.00 1.00 .3458 -.5305
485 5.00 1.00 .4860 -.2905
486 6.00 1.00 .6262 .0262
487 7.00 1.00 .7664 .4929
488 8.00 1.00 .9065 1.3929
489 test all the ties cases with low caseweight values
490 Variables Created By RANK
492 Variables Created By RANK
494 Variables Created By RANK
496 Variables Created By RANK
497 x into Nx(NORMAL of x using VW)
499 -------- -------- --------- --------- --------- ------
500 1.00 .10 .000 .100 1.000 -1.938
501 2.00 .10 .100 .200 2.000 -1.412
502 3.00 .10 .200 .300 3.000 -1.119
503 4.00 .20 .300 .500 4.000 -.8046
504 5.00 .10 .500 .600 5.000 -.5549
505 6.00 .10 .600 .700 6.000 -.4067
506 7.00 .10 .700 .800 7.000 -.2670
507 8.00 .10 .800 .900 8.000 -.1323
509 if [ $? -ne 0 ] ; then fail ; fi
513 # A test to make sure that variable name creation is really robust
514 activity="create file 4"
515 cat > $TESTFILE <<EOF
516 DATA LIST LIST notable /x * rx * ran001 TO ran999.
529 MODIFY VARS /drop ran001 TO ran999.
534 if [ $? -ne 0 ] ; then no_result ; fi
536 activity="run program 4"
537 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
538 if [ $? -ne 0 ] ; then fail ; fi
541 activity="compare output 4"
542 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
543 diff -b $TEMPDIR/pspp.list - << EOF
544 Variables Created By RANK
545 x into RNKRA01(RANK of x)
547 -------- -------- ---------
556 if [ $? -ne 0 ] ; then fail ; fi