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