SPLIT FILE: Convert test to Autotest framework.
[pspp-builds.git] / tests / bugs / t-test-paired.sh
1 #!/bin/sh
2
3 # This program tests for a bug in the paired samples T test.
4 # Thanks to Mike Griffiths for reporting this problem.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_srcdir and top_builddir  are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14
15 PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 cat >> $TESTFILE <<EOF
62 set format f8.3.
63 data list list /A * B *.
64 begin data.
65 11 2
66 1  1
67 1  1
68 end data.
69
70 t-test pairs = a with b (paired).
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="compare output"
81 diff -c $TEMPDIR/pspp.csv - << EOF
82 Table: Reading free-form data from INLINE.
83 Variable,Format
84 A,F8.0
85 B,F8.0
86
87 Table: Paired Sample Statistics
88 ,,Mean,N,Std. Deviation,S.E. Mean
89 Pair 0,A,4.333,3,5.774,3.333
90 ,B,1.333,3,.577,.333
91
92 Table: Paired Samples Correlations
93 ,,N,Correlation,Sig.
94 Pair 0,A & B,3,1.000,.000
95
96 Table: Paired Samples Test
97 ,,Paired Differences,,,,,,,
98 ,,,,,95% Confidence Interval of the Difference,,,,
99 ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed)
100 Pair 0,A - B,3.000,5.196,3.000,-9.908,15.908,1.000,2,.423
101 EOF
102 if [ $? -ne 0 ] ; then fail ; fi
103
104
105 pass;