708e5342b27c1f5a9a722acc89023233a03b4fad
[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 LANG=C
23 export LANG
24
25
26 cleanup()
27 {
28      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
29         echo "NOT cleaning $TEMPDIR" 
30         return ; 
31      fi
32      cd /
33      rm -rf $TEMPDIR
34 }
35
36
37 fail()
38 {
39     echo $activity
40     echo FAILED
41     cleanup;
42     exit 1;
43 }
44
45
46 no_result()
47 {
48     echo $activity
49     echo NO RESULT;
50     cleanup;
51     exit 2;
52 }
53
54 pass()
55 {
56     cleanup;
57     exit 0;
58 }
59
60 mkdir -p $TEMPDIR
61
62 cd $TEMPDIR
63
64 activity="create program"
65 cat > $TESTFILE <<EOF
66 DATA LIST LIST /X *.
67 BEGIN DATA.
68 2.00 
69 8.00 
70 5.00 
71 END DATA.
72
73 EXAMINE /x
74         /PERCENTILES=HAVERAGE.
75
76 EXAMINE /x
77         /PERCENTILES=WAVERAGE.
78
79 EXAMINE /x
80         /PERCENTILES=ROUND.
81
82 EXAMINE /x
83         /PERCENTILES=EMPIRICAL.
84
85 EXAMINE /x
86         /PERCENTILES=AEMPIRICAL.
87 EOF
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 activity="run program"
91 $SUPERVISOR $PSPP --testing-mode $TESTFILE
92 if [ $? -ne 0 ] ; then no_result ; fi
93
94
95 activity="compare results"
96 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
97 diff -b  $TEMPDIR/pspp.list - << EOF
98 1.1 DATA LIST.  Reading free-form data from INLINE.
99 +--------+------+
100 |Variable|Format|
101 #========#======#
102 |X       |F8.0  |
103 +--------+------+
104 2.1 EXAMINE.  Case Processing Summary
105 #=#=============================#
106 # #            Cases            #
107 # #---------+---------+---------#
108 # #  Valid  | Missing |  Total  #
109 # #-+-------+-+-------+-+-------#
110 # #N|Percent|N|Percent|N|Percent#
111 #=#=#=======#=#=======#=#=======#
112 #X#3|   100%|0|     0%|3|   100%#
113 #=#=#=======#=#=======#=#=======#
114 2.2 EXAMINE.  Percentiles
115 #================#================================#
116 #                #             Percentiles        #
117 #                #---+---+----+----+----+----+----#
118 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
119 #=#==============#===#===#====#====#====#====#====#
120 #X|HAverage      #.40|.80|2.00|5.00|8.00|8.00|8.00#
121 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
122 #=#==============#===#===#====#====#====#====#====#
123 3.1 EXAMINE.  Case Processing Summary
124 #=#=============================#
125 # #            Cases            #
126 # #---------+---------+---------#
127 # #  Valid  | Missing |  Total  #
128 # #-+-------+-+-------+-+-------#
129 # #N|Percent|N|Percent|N|Percent#
130 #=#=#=======#=#=======#=#=======#
131 #X#3|   100%|0|     0%|3|   100%#
132 #=#=#=======#=#=======#=#=======#
133 3.2 EXAMINE.  Percentiles
134 #==================#================================#
135 #                  #             Percentiles        #
136 #                  #---+---+----+----+----+----+----#
137 #                  # 5 | 10| 25 | 50 | 75 | 90 | 95 #
138 #=#================#===#===#====#====#====#====#====#
139 #X|Weighted Average#.30|.60|1.50|3.50|5.75|7.10|7.55#
140 # |Tukey's Hinges  #   |   |3.50|5.00|6.50|    |    #
141 #=#================#===#===#====#====#====#====#====#
142 4.1 EXAMINE.  Case Processing Summary
143 #=#=============================#
144 # #            Cases            #
145 # #---------+---------+---------#
146 # #  Valid  | Missing |  Total  #
147 # #-+-------+-+-------+-+-------#
148 # #N|Percent|N|Percent|N|Percent#
149 #=#=#=======#=#=======#=#=======#
150 #X#3|   100%|0|     0%|3|   100%#
151 #=#=#=======#=#=======#=#=======#
152 4.2 EXAMINE.  Percentiles
153 #================#================================#
154 #                #             Percentiles        #
155 #                #---+---+----+----+----+----+----#
156 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
157 #=#==============#===#===#====#====#====#====#====#
158 #X|Rounded       #.00|.00|2.00|5.00|5.00|8.00|8.00#
159 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
160 #=#==============#===#===#====#====#====#====#====#
161 5.1 EXAMINE.  Case Processing Summary
162 #=#=============================#
163 # #            Cases            #
164 # #---------+---------+---------#
165 # #  Valid  | Missing |  Total  #
166 # #-+-------+-+-------+-+-------#
167 # #N|Percent|N|Percent|N|Percent#
168 #=#=#=======#=#=======#=#=======#
169 #X#3|   100%|0|     0%|3|   100%#
170 #=#=#=======#=#=======#=#=======#
171 5.2 EXAMINE.  Percentiles
172 #================#==================================#
173 #                #              Percentiles         #
174 #                #----+----+----+----+----+----+----#
175 #                #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
176 #=#==============#====#====#====#====#====#====#====#
177 #X|Empirical     #2.00|2.00|2.00|5.00|8.00|8.00|8.00#
178 # |Tukey's Hinges#    |    |3.50|5.00|6.50|    |    #
179 #=#==============#====#====#====#====#====#====#====#
180 6.1 EXAMINE.  Case Processing Summary
181 #=#=============================#
182 # #            Cases            #
183 # #---------+---------+---------#
184 # #  Valid  | Missing |  Total  #
185 # #-+-------+-+-------+-+-------#
186 # #N|Percent|N|Percent|N|Percent#
187 #=#=#=======#=#=======#=#=======#
188 #X#3|   100%|0|     0%|3|   100%#
189 #=#=#=======#=#=======#=#=======#
190 6.2 EXAMINE.  Percentiles
191 #==========================#==================================#
192 #                          #              Percentiles         #
193 #                          #----+----+----+----+----+----+----#
194 #                          #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
195 #=#========================#====#====#====#====#====#====#====#
196 #X|Empirical with averaging#2.00|2.00|2.00|5.00|8.00|8.00|8.00#
197 # |Tukey's Hinges          #    |    |3.50|5.00|6.50|    |    #
198 #=#========================#====#====#====#====#====#====#====#
199 EOF
200 if [ $? -ne 0 ] ; then fail ; fi
201
202 pass