Fix use of "export" to work with traditional shells.
[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 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      rm -rf $TEMPDIR
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 activity="create program"
53 cat > $TESTFILE <<EOF
54 DATA LIST LIST /X *.
55 BEGIN DATA.
56 2.00 
57 8.00 
58 5.00 
59 END DATA.
60
61 EXAMINE /x
62         /PERCENTILES=HAVERAGE.
63
64 EXAMINE /x
65         /PERCENTILES=WAVERAGE.
66
67 EXAMINE /x
68         /PERCENTILES=ROUND.
69
70 EXAMINE /x
71         /PERCENTILES=EMPIRICAL.
72
73 EXAMINE /x
74         /PERCENTILES=AEMPIRICAL.
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="run program"
79 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82
83 activity="compare results"
84 diff -b -B $TEMPDIR/pspp.list - << EOF
85 1.1 DATA LIST.  Reading free-form data from the command file.
86 +--------+------+
87 |Variable|Format|
88 #========#======#
89 |X       |F8.0  |
90 +--------+------+
91
92 2.1 EXAMINE.  Case Processing Summary
93 #=#=============================#
94 # #            Cases            #
95 # #---------+---------+---------#
96 # #  Valid  | Missing |  Total  #
97 # #-+-------+-+-------+-+-------#
98 # #N|Percent|N|Percent|N|Percent#
99 #=#=#=======#=#=======#=#=======#
100 #X#3|   100%|0|     0%|3|   100%#
101 #=#=#=======#=#=======#=#=======#
102
103 2.2 EXAMINE.  Percentiles
104 #================#================================#
105 #                #             Percentiles        #
106 #                #---+---+----+----+----+----+----#
107 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
108 #=#==============#===#===#====#====#====#====#====#
109 #X|HAverage      #.40|.80|2.00|5.00|8.00|8.00|8.00#
110 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
111 #=#==============#===#===#====#====#====#====#====#
112
113 3.1 EXAMINE.  Case Processing Summary
114 #=#=============================#
115 # #            Cases            #
116 # #---------+---------+---------#
117 # #  Valid  | Missing |  Total  #
118 # #-+-------+-+-------+-+-------#
119 # #N|Percent|N|Percent|N|Percent#
120 #=#=#=======#=#=======#=#=======#
121 #X#3|   100%|0|     0%|3|   100%#
122 #=#=#=======#=#=======#=#=======#
123
124 3.2 EXAMINE.  Percentiles
125 #==================#================================#
126 #                  #             Percentiles        #
127 #                  #---+---+----+----+----+----+----#
128 #                  # 5 | 10| 25 | 50 | 75 | 90 | 95 #
129 #=#================#===#===#====#====#====#====#====#
130 #X|Weighted Average#.30|.60|1.50|3.50|5.75|7.10|7.55#
131 # |Tukey's Hinges  #   |   |3.50|5.00|6.50|    |    #
132 #=#================#===#===#====#====#====#====#====#
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
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
155 5.1 EXAMINE.  Case Processing Summary
156 #=#=============================#
157 # #            Cases            #
158 # #---------+---------+---------#
159 # #  Valid  | Missing |  Total  #
160 # #-+-------+-+-------+-+-------#
161 # #N|Percent|N|Percent|N|Percent#
162 #=#=#=======#=#=======#=#=======#
163 #X#3|   100%|0|     0%|3|   100%#
164 #=#=#=======#=#=======#=#=======#
165
166 5.2 EXAMINE.  Percentiles
167 #================#==================================#
168 #                #              Percentiles         #
169 #                #----+----+----+----+----+----+----#
170 #                #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
171 #=#==============#====#====#====#====#====#====#====#
172 #X|Empirical     #2.00|2.00|2.00|5.00|8.00|8.00|8.00#
173 # |Tukey's Hinges#    |    |3.50|5.00|6.50|    |    #
174 #=#==============#====#====#====#====#====#====#====#
175
176 6.1 EXAMINE.  Case Processing Summary
177 #=#=============================#
178 # #            Cases            #
179 # #---------+---------+---------#
180 # #  Valid  | Missing |  Total  #
181 # #-+-------+-+-------+-+-------#
182 # #N|Percent|N|Percent|N|Percent#
183 #=#=#=======#=#=======#=#=======#
184 #X#3|   100%|0|     0%|3|   100%#
185 #=#=#=======#=#=======#=#=======#
186
187 6.2 EXAMINE.  Percentiles
188 #==========================#==================================#
189 #                          #              Percentiles         #
190 #                          #----+----+----+----+----+----+----#
191 #                          #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
192 #=#========================#====#====#====#====#====#====#====#
193 #X|Empirical with averaging#2.00|2.00|2.00|5.00|8.00|8.00|8.00#
194 # |Tukey's Hinges          #    |    |3.50|5.00|6.50|    |    #
195 #=#========================#====#====#====#====#====#====#====#
196
197 EOF
198 if [ $? -ne 0 ] ; then fail ; fi
199
200 pass