Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / examine.sh
1 #!/bin/sh
2
3 # This program tests  the EXAMINE command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 DATA LIST LIST /QUALITY * W * BRAND * .
64 BEGIN DATA
65 3  1  1
66 2  2  1
67 1  2  1
68 1  1  1
69 4  1  1
70 4  1  1
71 5  1  2
72 2  1  2
73 4  4  2
74 2  1  2
75 3  1  2
76 7  1  3
77 4  2  3
78 5  3  3
79 3  1  3
80 6  1  3
81 END DATA
82
83 WEIGHT BY w.
84
85 VARIABLE LABELS brand   'Manufacturer'.
86 VARIABLE LABELS quality 'Breaking Strain'.
87
88 VALUE LABELS /brand 1 'Aspeger' 2 'Bloggs' 3 'Charlies'.
89
90 LIST /FORMAT=NUMBERED.
91
92 EXAMINE
93         quality BY brand
94         /STATISTICS descriptives extreme(3)
95         .
96 EOF
97 if [ $? -ne 0 ] ; then no_result ; fi
98
99
100 activity="run program"
101 $SUPERVISOR $PSPP --testing-mode $TESTFILE
102 if [ $? -ne 0 ] ; then no_result ; fi
103
104 # NOTE:  In the following data: Only the extreme values have been checked
105 # The descriptives have been blindly pasted.
106 activity="compare results"
107 diff -c $TEMPDIR/pspp.csv - << EOF
108 Table: Reading free-form data from INLINE.
109 Variable,Format
110 QUALITY,F8.0
111 W,F8.0
112 BRAND,F8.0
113
114 Table: Data List
115 Case Number,QUALITY,W,BRAND
116 1,3.00,1.00,1.00
117 2,2.00,2.00,1.00
118 3,1.00,2.00,1.00
119 4,1.00,1.00,1.00
120 5,4.00,1.00,1.00
121 6,4.00,1.00,1.00
122 7,5.00,1.00,2.00
123 8,2.00,1.00,2.00
124 9,4.00,4.00,2.00
125 10,2.00,1.00,2.00
126 11,3.00,1.00,2.00
127 12,7.00,1.00,3.00
128 13,4.00,2.00,3.00
129 14,5.00,3.00,3.00
130 15,3.00,1.00,3.00
131 16,6.00,1.00,3.00
132
133 Table: Case Processing Summary
134 ,Cases,,,,,
135 ,Valid,,Missing,,Total,
136 ,N,Percent,N,Percent,N,Percent
137 Breaking Strain,24.00,100%,.00,0%,24.00,100%
138
139 Table: Extreme Values
140 ,,,Case Number,Value
141 Breaking Strain,Highest,1,12,7.00
142 ,,2,16,6.00
143 ,,3,7,5.00
144 ,Lowest,1,3,1.00
145 ,,2,3,1.00
146 ,,3,4,1.00
147
148 Table: Descriptives
149 ,,,Statistic,Std. Error
150 Breaking Strain,Mean,,3.54,.32
151 ,95% Confidence Interval for Mean,Lower Bound,2.87,
152 ,,Upper Bound,4.21,
153 ,5% Trimmed Mean,,3.50,
154 ,Median,,4.00,
155 ,Variance,,2.52,
156 ,Std. Deviation,,1.59,
157 ,Minimum,,1.00,
158 ,Maximum,,7.00,
159 ,Range,,6.00,
160 ,Interquartile Range,,2.75,
161 ,Skewness,,.06,.47
162 ,Kurtosis,,-.36,.92
163
164 Table: Case Processing Summary
165 ,,Cases,,,,,
166 ,,Valid,,Missing,,Total,
167 ,Manufacturer,N,Percent,N,Percent,N,Percent
168 Breaking Strain,Aspeger,8.00,100%,.00,0%,8.00,100%
169 ,Bloggs,8.00,100%,.00,0%,8.00,100%
170 ,Charlies,8.00,100%,.00,0%,8.00,100%
171
172 Table: Extreme Values
173 ,Manufacturer,,,Case Number,Value
174 Breaking Strain,Aspeger,Highest,1,5,4.00
175 ,,,2,6,4.00
176 ,,,3,1,3.00
177 ,,Lowest,1,3,1.00
178 ,,,2,3,1.00
179 ,,,3,4,1.00
180 ,Bloggs,Highest,1,7,5.00
181 ,,,2,9,4.00
182 ,,,3,9,4.00
183 ,,Lowest,1,8,2.00
184 ,,,2,10,2.00
185 ,,,3,11,3.00
186 ,Charlies,Highest,1,12,7.00
187 ,,,2,16,6.00
188 ,,,3,14,5.00
189 ,,Lowest,1,15,3.00
190 ,,,2,13,4.00
191 ,,,3,13,4.00
192
193 Table: Descriptives
194 ,Manufacturer,,,Statistic,Std. Error
195 Breaking Strain,Aspeger,Mean,,2.25,.45
196 ,,95% Confidence Interval for Mean,Lower Bound,1.18,
197 ,,,Upper Bound,3.32,
198 ,,5% Trimmed Mean,,2.22,
199 ,,Median,,2.00,
200 ,,Variance,,1.64,
201 ,,Std. Deviation,,1.28,
202 ,,Minimum,,1.00,
203 ,,Maximum,,4.00,
204 ,,Range,,3.00,
205 ,,Interquartile Range,,2.75,
206 ,,Skewness,,.47,.75
207 ,,Kurtosis,,-1.55,1.48
208 ,Bloggs,Mean,,3.50,.38
209 ,,95% Confidence Interval for Mean,Lower Bound,2.61,
210 ,,,Upper Bound,4.39,
211 ,,5% Trimmed Mean,,3.50,
212 ,,Median,,4.00,
213 ,,Variance,,1.14,
214 ,,Std. Deviation,,1.07,
215 ,,Minimum,,2.00,
216 ,,Maximum,,5.00,
217 ,,Range,,3.00,
218 ,,Interquartile Range,,1.75,
219 ,,Skewness,,-.47,.75
220 ,,Kurtosis,,-.83,1.48
221 ,Charlies,Mean,,4.88,.44
222 ,,95% Confidence Interval for Mean,Lower Bound,3.83,
223 ,,,Upper Bound,5.92,
224 ,,5% Trimmed Mean,,4.86,
225 ,,Median,,5.00,
226 ,,Variance,,1.55,
227 ,,Std. Deviation,,1.25,
228 ,,Minimum,,3.00,
229 ,,Maximum,,7.00,
230 ,,Range,,4.00,
231 ,,Interquartile Range,,1.75,
232 ,,Skewness,,.30,.75
233 ,,Kurtosis,,.15,1.48
234 EOF
235 if [ $? -ne 0 ] ; then fail ; fi
236
237 pass