9a437efb8a466246a09859dc110d102c7dfc739a
[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      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 cat >> $TESTFILE <<EOF
63 data list list /x * gv (a8).
64 begin data.
65 3   One
66 2   One
67 3   One
68 2   One
69 3   One
70 4   Two
71 3.5 Two
72 3.0 Two
73 end data.
74
75 t-test group=gv('One', 'Two')
76         /variables = x.
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80
81 activity="run program"
82 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85
86 activity="compare output"
87 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
88 diff  -b  $TEMPDIR/pspp.list - << EOF
89 1.1 DATA LIST.  Reading free-form data from INLINE.
90 +--------+------+
91 |Variable|Format|
92 #========#======#
93 |x       |F8.0  |
94 |gv      |A8    |
95 +--------+------+
96 2.1 T-TEST.  Group Statistics
97 #==========#=#====#==============#========#
98 #     gv   |N|Mean|Std. Deviation|SE. Mean#
99 #==========#=#====#==============#========#
100 #x One     |5|2.60|           .55|     .24#
101 #  Two     |3|3.50|           .50|     .29#
102 #==========#=#====#==============#========#
103 2.2 T-TEST.  Independent Samples Test
104 #============================#=========#============================================================================#
105 #                            # Levene's|                        t-test for Equality of Means                        #
106 #                            #----+----+-----+----+---------------+---------------+---------------------+-----------#
107 #                            #    |    |     |    |               |               |                     |    95%    #
108 #                            #    |    |     |    |               |               |                     +-----+-----#
109 #                            #  F |Sig.|  t  | df |Sig. (2-tailed)|Mean Difference|Std. Error Difference|Lower|Upper#
110 #============================#====#====#=====#====#===============#===============#=====================#=====#=====#
111 #xEqual variances assumed    #1.13| .33|-2.32|6.00|            .06|           -.90|                  .38|-1.83|  .03#
112 # Equal variances not assumed#    |    |-2.38|4.70|            .07|           -.90|                  .38|-1.89|  .09#
113 #============================#====#====#=====#====#===============#===============#=====================#=====#=====#
114 EOF
115 if [ $? -ne 0 ] ; then fail ; fi
116
117
118 pass;