Search for a gettext implementation at configure time
[pspp-builds.git] / tests / command / trimmed-mean.sh
1 #!/bin/sh
2
3 # This program tests  the Trimmed Mean calculation, in the case
4 # where the data is weighted towards the centre
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
25 cleanup()
26 {
27      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
28         echo "NOT cleaning $TEMPDIR" 
29         return ; 
30      fi
31      cd /
32      rm -rf $TEMPDIR
33 }
34
35
36 fail()
37 {
38     echo $activity
39     echo FAILED
40     cleanup;
41     exit 1;
42 }
43
44
45 no_result()
46 {
47     echo $activity
48     echo NO RESULT;
49     cleanup;
50     exit 2;
51 }
52
53 pass()
54 {
55     cleanup;
56     exit 0;
57 }
58
59 mkdir -p $TEMPDIR
60
61 cd $TEMPDIR
62
63
64 activity="create program"
65 cat > $TESTFILE <<EOF
66 DATA LIST LIST /X * C *.
67 BEGIN DATA.
68 1 1
69 2 49
70 3 2
71 END DATA.
72
73 WEIGHT BY c.
74
75 EXAMINE
76         x
77         /STATISTICS=DESCRIPTIVES
78         .
79 EOF
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82
83 activity="run program"
84 $SUPERVISOR $PSPP --testing-mode $TESTFILE
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87
88 activity="compare results"
89 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
90 diff -b  $TEMPDIR/pspp.list - << EOF
91 1.1 DATA LIST.  Reading free-form data from INLINE.
92 +--------+------+
93 |Variable|Format|
94 #========#======#
95 |X       |F8.0  |
96 |C       |F8.0  |
97 +--------+------+
98 2.1 EXAMINE.  Case Processing Summary
99 #=#=======================================#
100 # #                 Cases                 #
101 # #-------------+-----------+-------------#
102 # #    Valid    |  Missing  |    Total    #
103 # #-----+-------+---+-------+-----+-------#
104 # #  N  |Percent| N |Percent|  N  |Percent#
105 #=#=====#=======#===#=======#=====#=======#
106 #X#52.00|   100%|.00|     0%|52.00|   100%#
107 #=#=====#=======#===#=======#=====#=======#
108 2.2 EXAMINE.  Descriptives
109 #==============================================#=========#==========#
110 #                                              #Statistic|Std. Error#
111 #==============================================#=========#==========#
112 #X Mean                                        #   2.02  |    .03   #
113 #  95% Confidence Interval for Mean Lower Bound#   1.95  |          #
114 #                                   Upper Bound#   2.09  |          #
115 #  5% Trimmed Mean                             #   2.00  |          #
116 #  Median                                      #   2.00  |          #
117 #  Variance                                    #   .06   |          #
118 #  Std. Deviation                              #   .24   |          #
119 #  Minimum                                     #   1.00  |          #
120 #  Maximum                                     #   3.00  |          #
121 #  Range                                       #   2.00  |          #
122 #  Interquartile Range                         #   .00   |          #
123 #  Skewness                                    #   1.19  |    .33   #
124 #  Kurtosis                                    #  15.73  |    .65   #
125 #==============================================#=========#==========#
126 EOF
127 if [ $? -ne 0 ] ; then fail ; fi
128
129 pass