T-TEST: Convert tests to Autotest framework.
[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$EXEEXT
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 -o pspp.csv $TESTFILE
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87
88 activity="compare results"
89 diff -c $TEMPDIR/pspp.csv - << EOF
90 Table: Reading free-form data from INLINE.
91 Variable,Format
92 X,F8.0
93 C,F8.0
94
95 Table: Case Processing Summary
96 ,Cases,,,,,
97 ,Valid,,Missing,,Total,
98 ,N,Percent,N,Percent,N,Percent
99 X,52.00,100%,.00,0%,52.00,100%
100
101 Table: Descriptives
102 ,,,Statistic,Std. Error
103 X,Mean,,2.02,.03
104 ,95% Confidence Interval for Mean,Lower Bound,1.95,
105 ,,Upper Bound,2.09,
106 ,5% Trimmed Mean,,2.00,
107 ,Median,,2.00,
108 ,Variance,,.06,
109 ,Std. Deviation,,.24,
110 ,Minimum,,1.00,
111 ,Maximum,,3.00,
112 ,Range,,2.00,
113 ,Interquartile Range,,.00,
114 ,Skewness,,1.19,.33
115 ,Kurtosis,,15.73,.65
116 EOF
117 if [ $? -ne 0 ] ; then fail ; fi
118
119 pass