25bd11255526bf0e183063a9565dbf2d6fd11f38
[pspp-builds.git] / tests / bugs / t-test-alpha3.sh
1 #!/bin/sh
2
3 # This program tests for a bug which didn't properly
4 # compare string values.
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
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 data list list /x * gv (a8).
63 begin data.
64 3   One
65 2   One
66 3   One
67 2   One
68 3   One
69 4   Two
70 3.5 Two
71 3.0 Two
72 end data.
73
74 t-test group=gv('One', 'Two')
75         /variables = x.
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="run program"
81 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84
85 activity="compare output"
86 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
87 diff  -b  $TEMPDIR/pspp.list - << EOF
88 1.1 DATA LIST.  Reading free-form data from INLINE.
89 +--------+------+
90 |Variable|Format|
91 #========#======#
92 |x       |F8.0  |
93 |gv      |A8    |
94 +--------+------+
95 2.1 T-TEST.  Group Statistics
96 #==========#=#====#==============#========#
97 #     gv   |N|Mean|Std. Deviation|SE. Mean#
98 #==========#=#====#==============#========#
99 #x One     |5|2.60|          .548|    .245#
100 #  Two     |3|3.50|          .500|    .289#
101 #==========#=#====#==============#========#
102 2.2 T-TEST.  Independent Samples Test
103 #============================#==========#===============================================================================#
104 #                            # Levene's |                          t-test for Equality of Means                         #
105 #                            #-----+----+------+-----+---------------+---------------+---------------------+------------#
106 #                            #     |    |      |     |               |               |                     |     95%    #
107 #                            #     |    |      |     |               |               |                     +------+-----#
108 #                            #  F  |Sig.|   t  |  df |Sig. (2-tailed)|Mean Difference|Std. Error Difference| Lower|Upper#
109 #============================#=====#====#======#=====#===============#===============#=====================#======#=====#
110 #xEqual variances assumed    #1.127|.329|-2.315|    6|           .060|          -.900|                 .379|-1.826| .026#
111 # Equal variances not assumed#     |    |-2.377|4.699|           .067|          -.900|                 .379|-1.892| .092#
112 #============================#=====#====#======#=====#===============#===============#=====================#======#=====#
113 EOF
114 if [ $? -ne 0 ] ; then fail ; fi
115
116
117 pass;