FREQUENCIES: Make frequency table headings easier to translate.
[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 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR" 
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62
63 i=1;
64
65 activity="create program $i"
66 cat > $TEMPDIR/prog.sps <<EOF
67 DATA LIST LIST notable /X * .
68 BEGIN DATA.
69
70
71
72
73 5
74 END DATA.
75
76 FREQUENCIES 
77         VAR=x
78         /ALGORITHM=COMPATIBLE
79         /PERCENTILES = 0 25 50 75 100
80
81 EOF
82 if [ $? -ne 0 ] ; then no_result; fi
83
84 activity="run program $i"
85 $SUPERVISOR $PSPP --testing-mode $TEMPDIR/prog.sps
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88 activity="compare output $i"
89 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
90 diff  -b $TEMPDIR/pspp.list - <<EOF
91 1.1 FREQUENCIES.  X
92 +-----------+--------+---------+--------+-------------+-----------+
93 |Value Label|  Value |Frequency| Percent|Valid Percent|Cum Percent|
94 #===========#========#=========#========#=============#===========#
95 |           |    1.00|        1|   20.00|        20.00|      20.00|
96 |           |    2.00|        1|   20.00|        20.00|      40.00|
97 |           |    3.00|        1|   20.00|        20.00|      60.00|
98 |           |    4.00|        1|   20.00|        20.00|      80.00|
99 |           |    5.00|        1|   20.00|        20.00|     100.00|
100 #===========#========#=========#========#=============#===========#
101 |               Total|        5|   100.0|        100.0|           |
102 +--------------------+---------+--------+-------------+-----------+
103 +-----------------------+----+
104 |N           Valid      |   5|
105 |            Missing    |   0|
106 |Mean                   |3.00|
107 |Std Dev                |1.58|
108 |Minimum                |1.00|
109 |Maximum                |5.00|
110 |Percentiles 0          |1.00|
111 |            25         |1.50|
112 |            50 (Median)|3.00|
113 |            75         |4.50|
114 |            100        |5.00|
115 +-----------------------+----+
116 EOF
117 if [ $? -ne 0 ] ; then fail ; fi
118
119 pass;