Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / t-test-1-indep-val.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /GROUPS command works properly 
4 # when a single value in the independent variable is given.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_builddir  are absolute
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
12 top_builddir=`cd $top_builddir; pwd`
13 PSPP=$top_builddir/src/ui/terminal/pspp
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      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
25         echo "NOT cleaning $TEMPDIR" 
26         return ; 
27      fi
28      cd /
29      rm -rf $TEMPDIR
30 }
31
32
33 fail()
34 {
35     echo $activity
36     echo FAILED
37     cleanup;
38     exit 1;
39 }
40
41
42 no_result()
43 {
44     echo $activity
45     echo NO RESULT;
46     cleanup;
47     exit 2;
48 }
49
50 pass()
51 {
52     cleanup;
53     exit 0;
54 }
55
56 mkdir -p $TEMPDIR
57
58 cd $TEMPDIR
59
60 activity="create program"
61 cat > $TESTFILE <<EOF
62 data list list /INDEP * DEP *.
63 begin data.
64        1        6
65        1        6
66        1        7
67        1        6
68        1       13
69        1        4
70        1        7
71        1        9
72        1        7
73        1       12
74        1       11
75        2       11
76        2        9
77        2        8
78        2        4
79        2       16
80        2        9
81        2        9
82        2        5
83        2        4
84        2       10
85        2       14
86 end data.
87 t-test /groups=indep(1.514) /var=dep.
88 EOF
89 if [ $? -ne 0 ] ; then no_result ; fi
90
91
92 activity="run program"
93 $SUPERVISOR $PSPP --testing-mode $TESTFILE
94 if [ $? -ne 0 ] ; then no_result ; fi
95
96
97 activity="compare output"
98 diff -c $TEMPDIR/pspp.csv - <<EOF
99 Table: Reading free-form data from INLINE.
100 Variable,Format
101 INDEP,F8.0
102 DEP,F8.0
103
104 Table: Group Statistics
105 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
106 DEP,>=1.514,11,9.00,3.82,1.15
107 ,<1.514,11,8.00,2.86,.86
108
109 Table: Independent Samples Test
110 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
111 ,,,,,,,,,95% Confidence Interval of the Difference,
112 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
113 DEP,Equal variances assumed,.17,.68,-.69,20.00,.50,-1.00,1.44,-4.00,2.00
114 ,Equal variances not assumed,,,-.69,18.54,.50,-1.00,1.44,-4.02,2.02
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118
119 pass