Fixed bug where an empty chart (one with no data) would crash.
[pspp] / tests / output / charts.at
1 AT_BANNER([CHARTS Rudimentary run tests])
2
3 dnl Check that the charts work
4 dnl Currently, "work" means that the commands which
5 dnl should generate them, run without crashing.
6 dnl Better tests will come later (hopefully)
7
8 AT_SETUP([Examine])
9 AT_DATA([charts.sps],[
10 input program.
11 loop #i = 1 to 1000.
12  compute x  = rv.normal (56, 3) + rv.uniform (1, 1).
13  compute y  = rv.normal (6, 2) + rv.uniform (1, 2).
14  compute A  = rv.uniform (-1, 1).
15   compute A = (A > 0).
16  end case.
17 end loop.
18 end file.
19 end input program.
20
21 examine x y by a
22         /plot = histogram, npplot spreadlevel(1)
23         .
24
25 examine x y by a
26         /compare = groups
27         /plot = boxplot
28         .
29
30 examine x y by a
31         /compare = variables
32         /plot = boxplot
33         .
34 ])
35
36 AT_CHECK([pspp -o pspp.txt charts.sps], [0], [ignore])
37
38 AT_CLEANUP
39
40 AT_SETUP([Roc])
41 AT_DATA([roc.sps],[
42 data list list /fred * group * w *.
43 begin data.
44 99  0 1000
45 99  1 3
46 97  0 908
47 97  1 2
48 95  0 904
49 96  1 7
50 94  1 9
51 93  0 823
52 93  1 12
53 90  0 723
54 90  1 42
55 84  0 523
56 84  1 98
57 73  0 500
58 75  1 180
59 63  0 520
60 69  1 320
61 60  0 510
62 60  1 418
63 50  0 488
64 54  1 432
65 46  0 428
66 43  1 528
67 36  0 324
68 36  1 612
69 26  0 294
70 28  1 682
71 20  0 119
72 20  1 719
73 10  0 97
74 10  1 809
75 end data.
76
77 weight by w.
78
79 compute bert = fred + (group < 0.5) * 45.
80 compute charlie = fred + (group > 0.5) * 15.
81
82
83 ROC /fred bert charlie by group (0)
84         /plot = curve (reference).
85
86 ])
87
88 AT_CHECK([pspp -o pspp.txt roc.sps], [0], [ignore])
89
90 AT_CLEANUP
91
92
93
94
95 AT_SETUP([Scree])
96 AT_DATA([scree.sps],[
97 input program.
98 vector vec(10).
99 loop #i = 1 to 100.
100  loop #v = 1 to 3.
101  compute vec(#v) = rv.normal (0, 45).
102  end loop.
103  loop #v = 4 to 10.
104  compute vec(#v) = vec (#v - 3) + rv.normal (0, 30).
105  end loop.
106  end case.
107 end loop.
108 end file.
109 end input program.
110
111
112 factor /variables = all
113         /print initial
114         /plot = eigen.
115
116 ])
117
118 AT_CHECK([pspp -o pspp.txt scree.sps], [0], [ignore])
119
120 AT_CLEANUP
121
122
123 AT_SETUP([Histogram])
124 AT_DATA([histogram.sps],[
125 * This test is designed to "torture" the code which
126   generates histograms.  It is no-crash test. However
127   the code is rich in assertions, so any problems we
128   hope will be caught there.
129   
130
131 input program.
132 loop #i = 1 to 1000.
133  compute pos  = rv.normal (56, 3) + rv.uniform (1, 1).
134  compute neg  = rv.normal (-86, 2) + rv.uniform (1, 1).
135  compute pn  = rv.normal (0, 2) + rv.uniform (1, 2).
136  compute A  = rv.uniform (-1, 1).
137   compute A = (A > 0).
138  end case.
139 end loop.
140 end file.
141 end input program.
142
143
144 examine pos neg pn by a
145         /plot = histogram
146         .
147
148 frequencies pos neg pn
149         /format=notable
150         /histogram=normal.
151 ])
152
153
154 dnl The --testing-mode flag is important!!
155 AT_CHECK([pspp --testing-mode -o pspp.txt histogram.sps], [0], [ignore])
156
157 AT_CLEANUP
158
159
160 AT_SETUP([FREQUENCIES charts])
161 AT_DATA([xxx.sps],[
162 DATA LIST LIST /nationality (A10)  religion (A20) gender (A8).
163 BEGIN DATA.
164 Australian  Sikh      Male
165 Australian  Sikh      Male
166 Australian  Sikh      Male
167 Australian  Sikh      Male
168 British     Zoroastrian Female
169 British     Buddist   Female
170 British     Buddist   Female
171 British      Zoroastrian Female
172 German      Muslim    Male
173 German      Christian Male
174 German      Christian Female
175 German      Christian Male
176 German      Zoroastrian Female
177 German      Sikh   Female
178 German      Muslim Female
179 German      Pastafarian Female
180 German      "Jedi Knight" Female
181 Belgian     Sikh      Male
182 French       Muslim      Male
183 French       Muslim      Male
184 French       Christian      Male
185 END DATA.
186
187
188 FREQUENCIES /VARIABLES=religion nationality /BARCHART /PIECHART. 
189 ])
190
191
192 AT_CHECK([pspp  -o pspp.txt xxx.sps], [0], [ignore])
193
194 AT_CLEANUP
195
196
197
198 AT_SETUP([CROSSTABS charts])
199 AT_DATA([xxx.sps],[
200 DATA LIST LIST /nationality (A10)  religion (A20) gender (A8).
201 BEGIN DATA.
202 Australian  Sikh      Male
203 Australian  Sikh      Male
204 Australian  Sikh      Male
205 Australian  Sikh      Male
206 British     Zoroastrian Female
207 British     Buddist   Female
208 British     Buddist   Female
209 British      Zoroastrian Female
210 German      Muslim    Male
211 German      Christian Male
212 German      Christian Female
213 German      Christian Male
214 German      Zoroastrian Female
215 German      Sikh   Female
216 German      Muslim Female
217 German      Pastafarian Female
218 German      "Jedi Knight" Female
219 Belgian     Sikh      Male
220 French       Muslim      Male
221 French       Muslim      Male
222 French       Christian      Male
223 END DATA.
224
225
226 CROSSTABS 
227           /tables = nationality by religion by gender
228           /tables = nationality by religion
229           /tables = religion by gender
230           /tables = nationality by religion by gender
231           /barchart.
232 ])
233
234
235 AT_CHECK([pspp  -o pspp.txt xxx.sps], [0], [ignore])
236
237 AT_CLEANUP
238
239
240
241
242 AT_SETUP([BOXPLOT Empty])
243 AT_DATA([bp.sps],[
244 DATA LIST LIST /X * Y * .
245 BEGIN DATA
246 1
247 2
248 2
249 2
250 3
251 END DATA
252
253 EXAMINE
254     /VARIABLES = Y
255     /PLOT = BOXPLOT.
256 ])
257
258
259 AT_CHECK([pspp -o pspp.txt bp.sps], [0], [ignore])
260
261 AT_CLEANUP
262
263
264
265
266
267
268
269
270
271