Remove the RESIZE feature of the sheet.
[pspp-builds.git] / tests / bugs / crosstabs2.sh
1 #!/bin/sh
2
3 # This program tests for bug #26739, which caused CROSSTABS to crash
4 # or to fail to output chi-square results.
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 LANG=C
22 export LANG
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 activity="create program"
63 cat > $TESTFILE <<EOF
64 DATA LIST LIST /x * y *.
65 BEGIN DATA.
66 2 2
67 3 1
68 4 2
69 4 1
70 END DATA.
71
72 CROSSTABS
73         /TABLES= x BY y
74         /STATISTICS=CHISQ
75        .
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 $SUPERVISOR $PSPP --testing-mode $TESTFILE
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82
83 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
84 diff -b  -w $TEMPDIR/pspp.list - << EOF
85 1.1 DATA LIST.  Reading free-form data from INLINE.
86 +--------+------+
87 |Variable|Format|
88 #========#======#
89 |x       |F8.0  |
90 |y       |F8.0  |
91 +--------+------+
92 2.1 CROSSTABS.  Summary.
93 #===============#=====================================================#
94 #               #                        Cases                        #
95 #               #-----------------+-----------------+-----------------#
96 #               #      Valid      |     Missing     |      Total      #
97 #               #--------+--------+--------+--------+--------+--------#
98 #               #       N| Percent|       N| Percent|       N| Percent#
99 #---------------#--------+--------+--------+--------+--------+--------#
100 #x * y          #       4|  100.0%|       0|    0.0%|       4|  100.0%#
101 #===============#========#========#========#========#========#========#
102 2.2 CROSSTABS.  x * y [count].
103 #===============#=================#========#
104 #               #        y        |        #
105 #               #--------+--------+        #
106 #              x#    1.00|    2.00|  Total #
107 #---------------#--------+--------+--------#
108 #           2.00#      .0|     1.0|     1.0#
109 #           3.00#     1.0|      .0|     1.0#
110 #           4.00#     1.0|     1.0|     2.0#
111 #Total          #     2.0|     2.0|     4.0#
112 #===============#========#========#========#
113 2.3 CROSSTABS.  Chi-square tests.
114 #===============#========#========#========#
115 #Statistic      #   Value|      df|  Asymp.#
116 #               #        |        |    Sig.#
117 #               #        |        |(2-sided#
118 #               #        |        |       )#
119 #---------------#--------+--------+--------#
120 #Pearson        #    2.00|       2|     .37#
121 #Chi-Square     #        |        |        #
122 #Likelihood     #    2.77|       2|     .25#
123 #Ratio          #        |        |        #
124 #Linear-by-Linea#     .27|       1|     .60#
125 #r Association  #        |        |        #
126 #N of Valid     #       4|        |        #
127 #Cases          #        |        |        #
128 #===============#========#========#========#
129 EOF
130 if [ $? -ne 0 ] ; then fail ; fi
131
132 pass;