Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / examine-percentiles.sh
1 #!/bin/sh
2
3 # This program tests  the PERCENTILES subcommand of the EXAMINE command.
4 # In particular it tests that it behaves properly when there are only 
5 # a few cases
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 # ensure that top_builddir  are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
18
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
21
22 LANG=C
23 export LANG
24
25
26 cleanup()
27 {
28      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
29         echo "NOT cleaning $TEMPDIR" 
30         return ; 
31      fi
32      cd /
33      rm -rf $TEMPDIR
34 }
35
36
37 fail()
38 {
39     echo $activity
40     echo FAILED
41     cleanup;
42     exit 1;
43 }
44
45
46 no_result()
47 {
48     echo $activity
49     echo NO RESULT;
50     cleanup;
51     exit 2;
52 }
53
54 pass()
55 {
56     cleanup;
57     exit 0;
58 }
59
60 mkdir -p $TEMPDIR
61
62 cd $TEMPDIR
63
64 activity="create program"
65 cat > $TESTFILE <<EOF
66 DATA LIST LIST /X *.
67 BEGIN DATA.
68 2.00 
69 8.00 
70 5.00 
71 END DATA.
72
73 EXAMINE /x
74         /PERCENTILES=HAVERAGE.
75
76 EXAMINE /x
77         /PERCENTILES=WAVERAGE.
78
79 EXAMINE /x
80         /PERCENTILES=ROUND.
81
82 EXAMINE /x
83         /PERCENTILES=EMPIRICAL.
84
85 EXAMINE /x
86         /PERCENTILES=AEMPIRICAL.
87 EOF
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 activity="run program"
91 $SUPERVISOR $PSPP --testing-mode $TESTFILE
92 if [ $? -ne 0 ] ; then no_result ; fi
93
94
95 activity="compare results"
96 diff -c $TEMPDIR/pspp.csv - << EOF
97 Table: Reading free-form data from INLINE.
98 Variable,Format
99 X,F8.0
100
101 Table: Case Processing Summary
102 ,Cases,,,,,
103 ,Valid,,Missing,,Total,
104 ,N,Percent,N,Percent,N,Percent
105 X,3,100%,0,0%,3,100%
106
107 Table: Percentiles
108 ,,Percentiles,,,,,,
109 ,,5,10,25,50,75,90,95
110 X,HAverage,.40,.80,2.00,5.00,8.00,8.00,8.00
111 ,Tukey's Hinges,,,3.50,5.00,6.50,,
112
113 Table: Case Processing Summary
114 ,Cases,,,,,
115 ,Valid,,Missing,,Total,
116 ,N,Percent,N,Percent,N,Percent
117 X,3,100%,0,0%,3,100%
118
119 Table: Percentiles
120 ,,Percentiles,,,,,,
121 ,,5,10,25,50,75,90,95
122 X,Weighted Average,.30,.60,1.50,3.50,5.75,7.10,7.55
123 ,Tukey's Hinges,,,3.50,5.00,6.50,,
124
125 Table: Case Processing Summary
126 ,Cases,,,,,
127 ,Valid,,Missing,,Total,
128 ,N,Percent,N,Percent,N,Percent
129 X,3,100%,0,0%,3,100%
130
131 Table: Percentiles
132 ,,Percentiles,,,,,,
133 ,,5,10,25,50,75,90,95
134 X,Rounded,.00,.00,2.00,5.00,5.00,8.00,8.00
135 ,Tukey's Hinges,,,3.50,5.00,6.50,,
136
137 Table: Case Processing Summary
138 ,Cases,,,,,
139 ,Valid,,Missing,,Total,
140 ,N,Percent,N,Percent,N,Percent
141 X,3,100%,0,0%,3,100%
142
143 Table: Percentiles
144 ,,Percentiles,,,,,,
145 ,,5,10,25,50,75,90,95
146 X,Empirical,2.00,2.00,2.00,5.00,8.00,8.00,8.00
147 ,Tukey's Hinges,,,3.50,5.00,6.50,,
148
149 Table: Case Processing Summary
150 ,Cases,,,,,
151 ,Valid,,Missing,,Total,
152 ,N,Percent,N,Percent,N,Percent
153 X,3,100%,0,0%,3,100%
154
155 Table: Percentiles
156 ,,Percentiles,,,,,,
157 ,,5,10,25,50,75,90,95
158 X,Empirical with averaging,2.00,2.00,2.00,5.00,8.00,8.00,8.00
159 ,Tukey's Hinges,,,3.50,5.00,6.50,,
160 EOF
161 if [ $? -ne 0 ] ; then fail ; fi
162
163 pass