Fixed a whole lot more memory leaks.
[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 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 export STAT_CONFIG_PATH=$top_srcdir/config
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 DATA LIST LIST /x * c *.
54 BEGIN DATA.
55 1 1
56 2 49
57 3 2
58 END DATA.
59
60 WEIGHT BY c.
61
62 EXAMINE
63         x
64         /STATISTICS=DESCRIPTIVES
65         .
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69
70 activity="run program"
71 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="compare results"
76 diff $TEMPDIR/pspp.list - << EOF
77 1.1 DATA LIST.  Reading free-form data from the command file.
78 +--------+------+
79 |Variable|Format|
80 #========#======#
81 |X       |F8.0  |
82 |C       |F8.0  |
83 +--------+------+
84
85 2.1 EXAMINE.  Case Processing Summary
86 #=#===============================#
87 # #             Cases             #
88 # #----------+---------+----------#
89 # #   Valid  | Missing |   Total  #
90 # #--+-------+-+-------+--+-------#
91 # # N|Percent|N|Percent| N|Percent#
92 #=#==#=======#=#=======#==#=======#
93 #X#52|   100%|0|     0%|52|   100%#
94 #=#==#=======#=#=======#==#=======#
95
96 2.2 EXAMINE.  Descriptives
97 #============================================#=========#==========#
98 #                                            #Statistic|Std. Error#
99 #============================================#=========#==========#
100 #XMean                                       #   2.02  |   .034   #
101 # 95% Confidence Interval for MeanLower Bound#  2.021  |          #
102 #                                 Upper Bound#  2.017  |          #
103 # 5% Trimmed Mean                            #   2.00  |          #
104 # Median                                     #   2.00  |          #
105 # Variance                                   #   .058  |          #
106 # Std. Deviation                             #   .242  |          #
107 # Minimum                                    #  1.000  |          #
108 # Maximum                                    #  3.000  |          #
109 # Range                                      #  2.000  |          #
110 # Interquartile Range                        #   .00   |          #
111 # Skewness                                   #  1.194  |   .330   #
112 # Kurtosis                                   #  15.732 |   .650   #
113 #============================================#=========#==========#
114
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118 pass