Fixed blank replacement
[pspp-builds.git] / tests / stats / percentiles-compatible.sh
1 #! /bin/sh
2
3 # Tests calculation of percentiles with the 
4 # COMPATIBLE algorithm set.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
20      rm -rf $TEMPDIR
21      :
22 }
23
24
25 fail()
26 {
27     echo $activity
28     echo FAILED
29     cleanup;
30     exit 1;
31 }
32
33
34 no_result()
35 {
36     echo $activity
37     echo NO RESULT;
38     cleanup;
39     exit 2;
40 }
41
42 pass()
43 {
44     cleanup;
45     exit 0;
46 }
47
48 mkdir -p $TEMPDIR
49
50 cd $TEMPDIR
51
52
53 i=1;
54
55 activity="create program $i"
56 cat > $TEMPDIR/prog.sps <<EOF
57 DATA LIST LIST notable /X * .
58 BEGIN DATA.
59
60
61
62
63 5
64 END DATA.
65
66 FREQUENCIES 
67         VAR=x
68         /ALGORITHM=COMPATIBLE
69         /PERCENTILES = 0 25 50 75 100
70
71 EOF
72 if [ $? -ne 0 ] ; then no_result; fi
73
74 activity="run program $i"
75 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="compare output $i"
79 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
80 diff  -b $TEMPDIR/pspp.list - <<EOF
81 1.1 FREQUENCIES.  X: 
82 +-----------+--------+---------+--------+--------+--------+
83 |           |        |         |        |  Valid |   Cum  |
84 |Value Label|  Value |Frequency| Percent| Percent| Percent|
85 #===========#========#=========#========#========#========#
86 |           |    1.00|        1|    20.0|    20.0|    20.0|
87 |           |    2.00|        1|    20.0|    20.0|    40.0|
88 |           |    3.00|        1|    20.0|    20.0|    60.0|
89 |           |    4.00|        1|    20.0|    20.0|    80.0|
90 |           |    5.00|        1|    20.0|    20.0|   100.0|
91 #===========#========#=========#========#========#========#
92 |               Total|        5|   100.0|   100.0|        |
93 +--------------------+---------+--------+--------+--------+
94 +-------------------+-----+
95 |N           Valid  |    5|
96 |            Missing|    0|
97 |Mean               |3.000|
98 |Std Dev            |1.581|
99 |Minimum            |1.000|
100 |Maximum            |5.000|
101 |Percentiles 0      |1.000|
102 |            25     |1.500|
103 |            50     |3.000|
104 |            75     |4.500|
105 |            100    |5.000|
106 +-------------------+-----+
107 EOF
108 if [ $? -ne 0 ] ; then fail ; fi
109
110 pass;