tests: Tag all the tests that take more than about 1s as "slow".
[pspp] / tests / language / stats / graph.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([GRAPH])
18
19 AT_SETUP([GRAPH simple scatterplot])
20 AT_DATA([scatterplot.sps],[
21 * Simple Scatterplot test
22 NEW FILE.
23 INPUT PROGRAM.
24 LOOP #i = 1 to 100.
25 COMPUTE Age = RV.NORMAL(40,10).
26 END CASE.
27 END LOOP.
28 END FILE.
29 END INPUT PROGRAM.
30
31 COMPUTE Size = Age * 3 + 50.
32
33 GRAPH
34     /SCATTERPLOT(BIVARIATE) = Age WITH Size. 
35
36 ])
37
38 AT_CHECK([pspp -O format=csv scatterplot.sps], [0], [ignore])
39
40 AT_CLEANUP
41
42
43 AT_SETUP([GRAPH Scatter and Histogram])
44 AT_KEYWORDS([slow])
45 AT_DATA([scatterlong.sps],[
46 NEW FILE.
47 INPUT PROGRAM.
48 LOOP #i = 1 to 10000.
49 COMPUTE Age = RV.NORMAL(40,10).
50 COMPUTE CityNum = TRUNC(UNIFORM(2.95)).
51 END CASE.
52 END LOOP.
53 END FILE.
54 END INPUT PROGRAM.
55
56 COMPUTE Size = Age * 3 + 50 + 50*CityNum.
57
58 STRING City (a20).
59
60 Recode CityNum 
61        (0 = "Madrid")
62        (1 = "Paris")
63        (ELSE = "Stockholm")
64        into City.
65
66  GRAPH
67     /SCATTERPLOT(BIVARIATE) = Age WITH Size 
68
69  GRAPH
70     /SCATTERPLOT(BIVARIATE) = Age WITH CityNum
71  
72  GRAPH
73     /SCATTERPLOT = CityNum WITH Age
74
75  GRAPH
76     /SCATTERPLOT = CityNum WITH Size
77
78  GRAPH
79     /SCATTERPLOT(BIVARIATE) = Age WITH Size BY City
80
81  GRAPH
82     /SCATTERPLOT(BIVARIATE) = Age WITH Size BY CityNum
83
84  ADD VALUE LABELS 
85     /CityNum 1 'Rio' 2 'Tokyo' 0 'Mumbai'.
86
87  GRAPH
88     /SCATTERPLOT(BIVARIATE) = Age WITH Size BY CityNum
89
90  GRAPH
91     /HISTOGRAM = Age.
92
93 ])
94
95 AT_CHECK([pspp -O format=pdf scatterlong.sps], [0], [ignore])
96 AT_CLEANUP
97
98 AT_SETUP([GRAPH missing values don't crash])
99 AT_DATA([scatter.sps], [dnl
100 data list list /x * y *.
101 begin data.
102 1 0
103 2 0
104 . 0
105 3 1
106 4 1
107 5 .
108 6 1
109 end data.
110 graph 
111       /scatterplot = x with y.
112 graph
113       /histogram = x. 
114 ])
115 AT_CHECK([pspp -o pspp.pdf scatter.sps])
116 dnl Ignore output -- this is just a no-crash check.
117 AT_CLEANUP
118
119 AT_SETUP([GRAPH missing=VARIABLE no crash])
120 AT_DATA([scatter.sps], [dnl
121 data list list /x * y *.
122 begin data.
123 1 0
124 2 0
125 . 0
126 3 1
127 4 1
128 5 .
129 6 1
130 end data.
131 graph 
132       /scatterplot = x with y
133       /missing = VARIABLE.
134 graph
135       /histogram = x
136       /missing = VARIABLE.
137 ])
138 AT_CHECK([pspp -o pspp.pdf scatter.sps])
139 dnl Ignore output -- this is just a no-crash check.
140 AT_CLEANUP
141
142 AT_SETUP([GRAPH missing value in by variable])
143 AT_DATA([scatter.sps], [dnl
144 data list list /x * y * z *.
145 begin data.
146 1 0 9
147 2 0 9
148 . 0 9
149 3 1 .
150 4 1 8
151 5 . 8
152 6 1 8
153 end data.
154 graph 
155       /scatterplot = x with y by z
156       /missing = VARIABLE.
157
158 graph 
159       /scatterplot = x with y by z.
160
161 ])
162 AT_CHECK([pspp -o pspp.pdf scatter.sps])
163 dnl Ignore output -- this is just a no-crash check.
164 AT_CLEANUP
165
166
167 AT_SETUP([GRAPH histogram with null data])
168 AT_DATA([null-hist.sps], [dnl
169 data list list /x *.
170 begin data.
171 1109 
172
173 end data.
174
175 graph 
176       /histogram = x.
177
178 ])
179
180 AT_CHECK([pspp -o pspp.pdf null-hist.sps], [0], [ignore])
181 dnl Ignore output -- this is just a no-crash check.
182 AT_CLEANUP
183
184
185 AT_SETUP([GRAPH histogram all missing])
186 AT_DATA([null-hist.sps], [dnl
187 data list list /x *.
188 begin data.
189
190 end data.
191
192 graph 
193       /histogram = x.
194
195 ])
196
197 AT_CHECK([pspp null-hist.sps], [0], [ignore])
198 dnl Ignore output -- this is just a no-crash check.
199 AT_CLEANUP
200
201
202
203
204 AT_SETUP([GRAPH barcharts])
205 AT_CHECK([ln -s $top_srcdir/examples/physiology.sav .], [0])
206 AT_CHECK([ln -s $top_srcdir/examples/repairs.sav .], [0])
207
208 AT_DATA([barchart.sps], [dnl
209 GET FILE="physiology.sav".
210
211 GRAPH /BAR = COUNT BY SEX.
212
213 GRAPH /BAR = MEAN(height) BY SEX.
214
215 NEW FILE.
216
217 GET FILE="repairs.sav".
218
219 GRAPH /BAR = MEAN (mtbf) BY factory.
220
221 COMPUTE  R = TRUNC(RV.UNIFORM(1,5)).
222
223 GRAPH /BAR = MEAN (mtbf) BY factory BY R.
224 ])
225
226 AT_CHECK([pspp -o pspp.pdf barchart.sps], [0], [ignore])
227 dnl Ignore output -- this is just a no-crash check.
228
229 AT_CLEANUP
230
231
232
233 AT_SETUP([GRAPH barchart arity])
234
235 AT_DATA([barchart.sps], [dnl
236 data list notable list /x y z*.
237 begin data
238 1  1  3
239 2  1  4
240 3  1  3
241 4  1  4
242 5  .  3
243 6  2  4
244 7  2  3
245 8  2  4
246 9  2  3
247 10  2  4
248 end data.
249
250 * This line is invalid
251 GRAPH /BAR = COUNT(x) BY y.
252 ])
253
254 AT_CHECK([pspp -o pspp.pdf barchart.sps], [1], [ignore])
255 dnl Ignore output -- this is just a no-crash check.
256
257 AT_CLEANUP
258
259
260
261
262 AT_SETUP([GRAPH barchart bad syntax])
263
264 AT_DATA([barchart.sps], [dnl
265 data list notable list /x y z*.
266 begin data
267 1  1  3
268 2  1  4
269 3  1  3
270 4  1  4
271 5  .  3
272 6  2  4
273 7  2  3
274 8  2  4
275 9  2  3
276 10  2  4
277 end data.
278
279 * This line is invalid
280 GRAPH /BAR = SCROD BY y.
281 ])
282
283 AT_CHECK([pspp -o pspp.pdf barchart.sps], [1], [ignore])
284 dnl Ignore output -- this is just a no-crash check.
285
286 AT_CLEANUP
287
288
289
290 AT_SETUP([GRAPH barchart full])
291
292 AT_DATA([barchart.sps], [dnl
293 data list notable list /x y z*.
294 begin data
295 1  1  3
296 2  1  4
297 3  1  3
298 4  1  4
299 5  .  3
300 6  2  4
301 7  2  3
302 8  2  4
303 9  2  3
304 10  2  4
305 end data.
306
307 * This line is invalid
308 GRAPH /BAR = COUNT by z.
309 GRAPH /BAR = CUFREQ by z.
310 GRAPH /BAR = PCT by z.
311 GRAPH /BAR = CUPCT by z.
312
313 GRAPH /BAR = MEAN(y) BY z.
314 GRAPH /BAR = SUM(y) BY z.
315 GRAPH /BAR = MAXIMUM(y) BY z.
316 GRAPH /BAR = MINIMUM(y) BY z.
317
318 GRAPH /BAR = MEAN(y) BY z BY y.
319 GRAPH /BAR = SUM(y) BY z BY y.
320 GRAPH /BAR = MAXIMUM(y) BY z BY y.
321 GRAPH /BAR = MINIMUM(y) BY z BY y.
322 ])
323
324 AT_CHECK([pspp -o pspp.pdf barchart.sps], [0], [ignore])
325 dnl Ignore output -- this is just a no-crash check.
326
327 AT_CLEANUP
328
329
330
331
332
333 AT_SETUP([GRAPH buggy syntax])
334
335 AT_DATA([barchart.sps], [dnl
336 data list notable list /x y z*.
337 begin data
338 1  1  3
339 2  1  4
340 10  2  4
341 end data.
342
343 GRAPH /BAR = MINIMUM({) BY z BY y.
344 ])
345
346 AT_CHECK([pspp -o pspp.pdf barchart.sps], [1], [ignore])
347 dnl Ignore output -- this is just a no-crash check.
348
349 AT_CLEANUP