3 # This program tests the chisquare subcommand of the NPAR command.
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
8 # ensure that top_srcdir and top_builddir are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
25 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
26 echo "NOT cleaning $TEMPDIR"
61 activity="create file 1"
63 DATA LIST NOTABLE LIST /x * y * w *.
91 if [ $? -ne 0 ] ; then no_result ; fi
94 activity="run program 1"
95 $SUPERVISOR $PSPP --testing-mode $TESTFILE
96 if [ $? -ne 0 ] ; then no_result ; fi
98 activity="compare output 1"
99 diff -c $TEMPDIR/pspp.csv - << EOF
101 ,Observed N,Expected N,Residual
111 ,Observed N,Expected N,Residual
118 Table: Test Statistics
125 ,Observed N,Expected N,Residual
132 Table: Test Statistics
140 ,Category,Observed N,Expected N,Residual,Category,Observed N,Expected N,Residual
141 1,2.00,3.00,3.16,-.16,2.00,4.00,2.21,1.79
142 2,3.00,5.00,5.26,-.26,3.00,1.00,3.68,-2.68
143 3,4.00,2.00,1.58,.42,4.00,2.00,1.11,.89
144 Total,,10.00,,,,7.00,,
146 Table: Test Statistics
152 if [ $? -ne 0 ] ; then fail ; fi
155 activity="create file 2"
156 cat <<EOF > $TESTFILE
157 DATA LIST NOTABLE LIST /x * y * w *.
172 /EXPECTED = 3 4 5 4 3 1
175 if [ $? -ne 0 ] ; then no_result ; fi
178 activity="run program 2"
179 $SUPERVISOR $PSPP --testing-mode $TESTFILE > $TEMPDIR/output
180 if [ $? -eq 0 ] ; then no_result ; fi
182 activity="compare errors 2"
183 perl -pi -e 's/^\s*$//g' $TEMPDIR/output
184 diff -b $TEMPDIR/output - << EOF
185 error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y.
187 if [ $? -ne 0 ] ; then fail ; fi
190 activity="create file 3"
191 cat <<EOF > $TESTFILE
192 DATA LIST NOTABLE LIST /x * y * w * .
206 MISSING VALUES x (4).
211 /STATISTICS=DESCRIPTIVES
214 if [ $? -ne 0 ] ; then no_result ; fi
217 activity="run program 3"
218 $SUPERVISOR $PSPP --testing-mode $TESTFILE
219 if [ $? -ne 0 ] ; then no_result ; fi
222 activity="compare output 3"
223 diff -c $TEMPDIR/pspp.csv - <<EOF
226 ,Category,Observed N,Expected N,Residual,Category,Observed N,Expected N,Residual
227 1,-2.00,.00,1.50,-1.50,-2.00,.00,1.88,-1.88
228 2,-1.00,.00,1.50,-1.50,-1.00,.00,1.88,-1.88
229 3,.00,.00,1.50,-1.50,.00,.00,1.88,-1.88
230 4,1.00,3.00,1.50,1.50,1.00,7.00,1.88,5.13
231 5,2.00,3.00,1.50,1.50,2.00,4.00,1.88,2.13
232 6,3.00,5.00,1.50,3.50,3.00,1.00,1.88,-.88
233 7,4.00,.00,1.50,-1.50,4.00,2.00,1.88,.13
234 8,5.00,1.00,1.50,-.50,5.00,1.00,1.88,-.88
235 Total,,12.00,,,,15.00,,
237 Table: Test Statistics
239 Chi-Square,17.33,22.87
243 Table: Descriptive Statistics
244 ,N,Mean,Std. Deviation,Minimum,Maximum
246 x,12.00,2.47,1.19,1.00,5.00
247 y,15.00,2.07,1.33,1.00,5.00
249 if [ $? -ne 0 ] ; then fail ; fi
252 activity="create file 4"
253 cat <<EOF > $TESTFILE
254 DATA LIST NOTABLE LIST /x * y * w * .
268 * MISSING VALUES x (4).
273 /STATISTICS=DESCRIPTIVES
276 if [ $? -ne 0 ] ; then no_result ; fi
279 activity="run program 4"
280 $SUPERVISOR $PSPP --testing-mode $TESTFILE
281 if [ $? -ne 0 ] ; then no_result ; fi
284 activity="compare output 4"
285 diff -c $TEMPDIR/pspp.csv - <<EOF
288 ,Category,Observed N,Expected N,Residual,Category,Observed N,Expected N,Residual
289 1,-2.00,.00,1.75,-1.75,-2.00,.00,1.75,-1.75
290 2,-1.00,.00,1.75,-1.75,-1.00,.00,1.75,-1.75
291 3,.00,.00,1.75,-1.75,.00,.00,1.75,-1.75
292 4,1.00,3.00,1.75,1.25,1.00,7.00,1.75,5.25
293 5,2.00,3.00,1.75,1.25,2.00,4.00,1.75,2.25
294 6,3.00,5.00,1.75,3.25,3.00,1.00,1.75,-.75
295 7,4.00,2.00,1.75,.25,4.00,2.00,1.75,.25
296 8,5.00,1.00,1.75,-.75,5.00,.00,1.75,-1.75
297 Total,,14.00,,,,14.00,,
299 Table: Test Statistics
301 Chi-Square,13.43,26.00
305 Table: Descriptive Statistics
306 ,N,Mean,Std. Deviation,Minimum,Maximum
308 x,14.00,2.69,1.23,1.00,5.00
309 y,14.00,1.86,1.10,1.00,4.00
311 if [ $? -ne 0 ] ; then fail ; fi