3759710b2629bb684089d202a3288382b1937d55
[pspp-builds.git] / tests / command / examine-percentiles.sh
1 #!/bin/sh
2
3 # This program tests  the PERCENTILES subcommand of the EXAMINE command.
4 # In particular it tests that it behaves properly when there are only 
5 # a few cases
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 # ensure that top_builddir  are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
18
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
21
22
23 cleanup()
24 {
25      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 activity="create program"
58 cat > $TESTFILE <<EOF
59 DATA LIST LIST /X *.
60 BEGIN DATA.
61 2.00 
62 8.00 
63 5.00 
64 END DATA.
65
66 EXAMINE /x
67         /PERCENTILES=HAVERAGE.
68
69 EXAMINE /x
70         /PERCENTILES=WAVERAGE.
71
72 EXAMINE /x
73         /PERCENTILES=ROUND.
74
75 EXAMINE /x
76         /PERCENTILES=EMPIRICAL.
77
78 EXAMINE /x
79         /PERCENTILES=AEMPIRICAL.
80 EOF
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83 activity="run program"
84 $SUPERVISOR $PSPP -o raw-ascii $TESTFILE
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87
88 activity="compare results"
89 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
90 diff -b  $TEMPDIR/pspp.list - << EOF
91 1.1 DATA LIST.  Reading free-form data from INLINE.
92 +--------+------+
93 |Variable|Format|
94 #========#======#
95 |X       |F8.0  |
96 +--------+------+
97 2.1 EXAMINE.  Case Processing Summary
98 #=#=============================#
99 # #            Cases            #
100 # #---------+---------+---------#
101 # #  Valid  | Missing |  Total  #
102 # #-+-------+-+-------+-+-------#
103 # #N|Percent|N|Percent|N|Percent#
104 #=#=#=======#=#=======#=#=======#
105 #X#3|   100%|0|     0%|3|   100%#
106 #=#=#=======#=#=======#=#=======#
107 2.2 EXAMINE.  Percentiles
108 #================#================================#
109 #                #             Percentiles        #
110 #                #---+---+----+----+----+----+----#
111 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
112 #=#==============#===#===#====#====#====#====#====#
113 #X|HAverage      #.40|.80|2.00|5.00|8.00|8.00|8.00#
114 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
115 #=#==============#===#===#====#====#====#====#====#
116 3.1 EXAMINE.  Case Processing Summary
117 #=#=============================#
118 # #            Cases            #
119 # #---------+---------+---------#
120 # #  Valid  | Missing |  Total  #
121 # #-+-------+-+-------+-+-------#
122 # #N|Percent|N|Percent|N|Percent#
123 #=#=#=======#=#=======#=#=======#
124 #X#3|   100%|0|     0%|3|   100%#
125 #=#=#=======#=#=======#=#=======#
126 3.2 EXAMINE.  Percentiles
127 #==================#================================#
128 #                  #             Percentiles        #
129 #                  #---+---+----+----+----+----+----#
130 #                  # 5 | 10| 25 | 50 | 75 | 90 | 95 #
131 #=#================#===#===#====#====#====#====#====#
132 #X|Weighted Average#.30|.60|1.50|3.50|5.75|7.10|7.55#
133 # |Tukey's Hinges  #   |   |3.50|5.00|6.50|    |    #
134 #=#================#===#===#====#====#====#====#====#
135 4.1 EXAMINE.  Case Processing Summary
136 #=#=============================#
137 # #            Cases            #
138 # #---------+---------+---------#
139 # #  Valid  | Missing |  Total  #
140 # #-+-------+-+-------+-+-------#
141 # #N|Percent|N|Percent|N|Percent#
142 #=#=#=======#=#=======#=#=======#
143 #X#3|   100%|0|     0%|3|   100%#
144 #=#=#=======#=#=======#=#=======#
145 4.2 EXAMINE.  Percentiles
146 #================#================================#
147 #                #             Percentiles        #
148 #                #---+---+----+----+----+----+----#
149 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
150 #=#==============#===#===#====#====#====#====#====#
151 #X|Rounded       #.00|.00|2.00|5.00|5.00|8.00|8.00#
152 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
153 #=#==============#===#===#====#====#====#====#====#
154 5.1 EXAMINE.  Case Processing Summary
155 #=#=============================#
156 # #            Cases            #
157 # #---------+---------+---------#
158 # #  Valid  | Missing |  Total  #
159 # #-+-------+-+-------+-+-------#
160 # #N|Percent|N|Percent|N|Percent#
161 #=#=#=======#=#=======#=#=======#
162 #X#3|   100%|0|     0%|3|   100%#
163 #=#=#=======#=#=======#=#=======#
164 5.2 EXAMINE.  Percentiles
165 #================#==================================#
166 #                #              Percentiles         #
167 #                #----+----+----+----+----+----+----#
168 #                #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
169 #=#==============#====#====#====#====#====#====#====#
170 #X|Empirical     #2.00|2.00|2.00|5.00|8.00|8.00|8.00#
171 # |Tukey's Hinges#    |    |3.50|5.00|6.50|    |    #
172 #=#==============#====#====#====#====#====#====#====#
173 6.1 EXAMINE.  Case Processing Summary
174 #=#=============================#
175 # #            Cases            #
176 # #---------+---------+---------#
177 # #  Valid  | Missing |  Total  #
178 # #-+-------+-+-------+-+-------#
179 # #N|Percent|N|Percent|N|Percent#
180 #=#=#=======#=#=======#=#=======#
181 #X#3|   100%|0|     0%|3|   100%#
182 #=#=#=======#=#=======#=#=======#
183 6.2 EXAMINE.  Percentiles
184 #==========================#==================================#
185 #                          #              Percentiles         #
186 #                          #----+----+----+----+----+----+----#
187 #                          #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
188 #=#========================#====#====#====#====#====#====#====#
189 #X|Empirical with averaging#2.00|2.00|2.00|5.00|8.00|8.00|8.00#
190 # |Tukey's Hinges          #    |    |3.50|5.00|6.50|    |    #
191 #=#========================#====#====#====#====#====#====#====#
192 EOF
193 if [ $? -ne 0 ] ; then fail ; fi
194
195 pass