f8f21a4c1c78733f75a49e84b8e0cf222979a720
[pspp] / tests / language / dictionary / mrsets.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([MRSETS])
18
19 m4_define([DEFINE_MRSETS_DATA],
20   [DATA LIST NOTABLE /w x y z 1-4 a b c d 5-8 (a).
21 BEGIN DATA.
22 1234acbd
23 5678efgh
24 END DATA.])
25
26 m4_define([DEFINE_MRSETS],
27   [DEFINE_MRSETS_DATA
28
29 [VARIABLE LABEL
30     w 'duplicate variable label'
31     x 'Variable x'
32     z 'Duplicate variable label'.
33 VALUE LABELS
34     /w 1 'w value 1'
35     /y 1 'duplicate Value label'
36     /z 1 'duplicate value Label'
37     /a b c d 'a' 'burger' 'b' 'fries' 'c' 'shake' 'd' 'taco'.
38 ADD VALUE LABELS
39     /b 'b' 'Fries'
40     /c 'b' 'XXX'.
41 MRSETS
42     /MDGROUP NAME=$a
43      LABEL='First multiple dichotomy group'
44      CATEGORYLABELS=VARLABELS
45      VARIABLES=w x y z
46      VALUE=5
47     /MDGROUP NAME=$b
48      CATEGORYLABELS=COUNTEDVALUES
49      VARIABLES=z y
50      VALUE=123
51     /MDGROUP NAME=$c
52      LABELSOURCE=VARLABEL
53      CATEGORYLABELS=COUNTEDVALUES
54      VARIABLES=w x y z
55      VALUE=1
56     /MDGROUP NAME=$d
57      LABELSOURCE=VARLABEL
58      VARIABLES=a b c d
59      VALUE='c'
60     /MCGROUP NAME=$e
61      LABEL='First multiple category group'
62      VARIABLES=w x y z
63     /MCGROUP NAME=$f
64      VARIABLES=a b c d.
65 ]])
66
67 m4_define([DEFINE_MRSETS_OUTPUT], [dnl
68 "mrsets.sps:23.16-23.22: warning: MRSETS: Variables w and z specified as part of multiple dichotomy group $a have the same variable label.  Categories represented by these variables will not be distinguishable in output.
69    23 |      VARIABLES=w x y z
70       |                ^~~~~~~"
71
72 "mrsets.sps:27.16-27.18: warning: MRSETS: Variable z specified as part of multiple dichotomy group $b (which has CATEGORYLABELS=COUNTEDVALUES) has no value label for its counted value.  This category will not be distinguishable in output.
73    27 |      VARIABLES=z y
74       |                ^~~"
75
76 "mrsets.sps:27.16-27.18: warning: MRSETS: Variable y specified as part of multiple dichotomy group $b (which has CATEGORYLABELS=COUNTEDVALUES) has no value label for its counted value.  This category will not be distinguishable in output.
77    27 |      VARIABLES=z y
78       |                ^~~"
79
80 "mrsets.sps:32.16-32.22: warning: MRSETS: Variable x specified as part of multiple dichotomy group $c (which has CATEGORYLABELS=COUNTEDVALUES) has no value label for its counted value.  This category will not be distinguishable in output.
81    32 |      VARIABLES=w x y z
82       |                ^~~~~~~"
83
84 "mrsets.sps:32.16-32.22: warning: MRSETS: Variables y and z specified as part of multiple dichotomy group $c (which has CATEGORYLABELS=COUNTEDVALUES) have the same value label for the group's counted value.  These categories will not be distinguishable in output.
85    32 |      VARIABLES=w x y z
86       |                ^~~~~~~"
87
88 "mrsets.sps:35.6-35.25: warning: MRSETS: MDGROUP subcommand for group $d specifies LABELSOURCE=VARLABEL but not CATEGORYLABELS=COUNTEDVALUES.  Ignoring LABELSOURCE.
89    35 |      LABELSOURCE=VARLABEL
90       |      ^~~~~~~~~~~~~~~~~~~~"
91
92 "mrsets.sps:40.16-40.22: warning: MRSETS: Variables specified on MCGROUP should have the same categories, but w and y (and possibly others) in multiple category group $e have different value labels for value 1.
93    40 |      VARIABLES=w x y z
94       |                ^~~~~~~"
95
96 "mrsets.sps:42.16-42.22: warning: MRSETS: Variables specified on MCGROUP should have the same categories, but a and c (and possibly others) in multiple category group $f have different value labels for value b.
97    42 |      VARIABLES=a b c d.
98       |                ^~~~~~~"
99 ])
100
101 m4_define([MRSETS_DISPLAY_OUTPUT], [dnl
102 Table: Multiple Response Sets
103 Name,Label,Encoding,Counted Value,Member Variables
104 $a,First multiple dichotomy group,Dichotomies,5,"w
105 x
106 y
107 z"
108 $b,,Dichotomies,123,"z
109 y"
110 $c,duplicate variable label,Dichotomies,1,"w
111 x
112 y
113 z"
114 $d,,Dichotomies,c,"a
115 b
116 c
117 d"
118 $e,First multiple category group,Categories,,"w
119 x
120 y
121 z"
122 $f,,Categories,,"a
123 b
124 c
125 d"
126 ])
127
128 AT_SETUP([MRSETS add, display, delete])
129 AT_DATA([mrsets.sps],
130   [DEFINE_MRSETS
131 [MRSETS
132     /DISPLAY NAME=[$a]
133     /DISPLAY NAME=ALL
134     /DELETE NAME=[$c]
135     /DISPLAY NAME=ALL
136     /DELETE NAME=ALL
137     /DISPLAY NAME=ALL.
138 ]])
139 AT_CHECK([pspp -o - -O format=csv -o mrsets.csv -o mrsets.txt mrsets.sps], [0],
140   [DEFINE_MRSETS_OUTPUT
141 Table: Multiple Response Sets
142 Name,Label,Encoding,Counted Value,Member Variables
143 $a,First multiple dichotomy group,Dichotomies,5,"w
144 x
145 y
146 z"
147
148 Table: Multiple Response Sets
149 Name,Label,Encoding,Counted Value,Member Variables
150 $a,First multiple dichotomy group,Dichotomies,5,"w
151 x
152 y
153 z"
154 $b,,Dichotomies,123,"z
155 y"
156 $c,duplicate variable label,Dichotomies,1,"w
157 x
158 y
159 z"
160 $d,,Dichotomies,c,"a
161 b
162 c
163 d"
164 $e,First multiple category group,Categories,,"w
165 x
166 y
167 z"
168 $f,,Categories,,"a
169 b
170 c
171 d"
172
173 Table: Multiple Response Sets
174 Name,Label,Encoding,Counted Value,Member Variables
175 $a,First multiple dichotomy group,Dichotomies,5,"w
176 x
177 y
178 z"
179 $b,,Dichotomies,123,"z
180 y"
181 $d,,Dichotomies,c,"a
182 b
183 c
184 d"
185 $e,First multiple category group,Categories,,"w
186 x
187 y
188 z"
189 $f,,Categories,,"a
190 b
191 c
192 d"
193
194 "mrsets.sps:50.19-50.21: note: MRSETS: The active dataset dictionary does not contain any multiple response sets.
195    50 |     /DISPLAY NAME=ALL.
196       |                   ^~~"
197 ])
198 AT_CLEANUP
199
200 AT_SETUP([MRSETS read and write])
201 AT_DATA([mrsets.sps],
202   [DEFINE_MRSETS
203 SAVE OUTFILE='mrsets.sav'.
204 ])
205 AT_CHECK([pspp -O format=csv mrsets.sps], [0], [DEFINE_MRSETS_OUTPUT])
206 AT_DATA([mrsets2.sps],
207   [GET FILE='mrsets.sav'.
208 MRSETS /DISPLAY NAME=ALL.
209 ])
210 AT_CHECK([pspp -O format=csv mrsets2.sps], [0], [MRSETS_DISPLAY_OUTPUT],
211   [], [hd mrsets.sav])
212 AT_CLEANUP
213
214 AT_SETUP([MRSETS names must begin with $])
215 AT_DATA([mrsets.sps],
216   [DEFINE_MRSETS_DATA
217 MRSETS /MCGROUP NAME=x.
218 ])
219 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
220 "mrsets.sps:6.22: error: MRSETS: x is not a valid name for a multiple response set.  Multiple response set names must begin with `$'.
221     6 | MRSETS /MCGROUP NAME=x.
222       |                      ^"
223 ])
224 AT_CLEANUP
225
226 AT_SETUP([MRSETS must have at least 2 variables])
227 AT_DATA([mrsets.sps],
228   [DEFINE_MRSETS_DATA
229 MRSETS /MCGROUP NAME=$x VARIABLES=a.
230 ])
231 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
232 "mrsets.sps:6.35: error: MRSETS: VARIABLES specified only variable a on MCGROUP, but at least two variables are required.
233     6 | MRSETS /MCGROUP NAME=$x VARIABLES=a.
234       |                                   ^"
235 ])
236 AT_CLEANUP
237
238 AT_SETUP([MRSETS does not allow noninteger VALUE])
239 AT_DATA([mrsets.sps],
240   [DEFINE_MRSETS_DATA
241 MRSETS /MDGROUP VALUE=1.5.
242 ])
243 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
244 "mrsets.sps:6.23-6.25: error: MRSETS: Numeric VALUE must be an integer.
245     6 | MRSETS /MDGROUP VALUE=1.5.
246       |                       ^~~"
247 ])
248 AT_CLEANUP
249
250 AT_SETUP([MRSETS requires NAME to define a group])
251 AT_DATA([mrsets.sps],
252   [DEFINE_MRSETS_DATA
253 MRSETS /MCGROUP VARIABLES=a b c.
254 ])
255 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
256 "mrsets.sps:6.32: error: MRSETS: Required NAME specification missing from MCGROUP subcommand.
257     6 | MRSETS /MCGROUP VARIABLES=a b c.
258       |                                ^"
259 ])
260 AT_CLEANUP
261
262 AT_SETUP([MRSETS requires VARIABLES to define a group])
263 AT_DATA([mrsets.sps],
264   [DEFINE_MRSETS_DATA
265 MRSETS /MCGROUP NAME=$Mcgroup.
266 ])
267 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
268 "mrsets.sps:6.30: error: MRSETS: Required VARIABLES specification missing from MCGROUP subcommand.
269     6 | MRSETS /MCGROUP NAME=$Mcgroup.
270       |                              ^"
271 ])
272 AT_CLEANUP
273
274 AT_SETUP([MRSETS variables must be same type])
275 AT_DATA([mrsets.sps],
276   [DEFINE_MRSETS_DATA
277 MRSETS /MCGROUP NAME=$mygroup VARIABLES=a b x y.
278 ])
279 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
280 "mrsets.sps:6.45: error: MRSETS: a and x are not the same type.  All variables in this variable list must be of the same type.  x will be omitted from the list.
281     6 | MRSETS /MCGROUP NAME=$mygroup VARIABLES=a b x y.
282       |                                             ^"
283
284 "mrsets.sps:6.47: error: MRSETS: a and y are not the same type.  All variables in this variable list must be of the same type.  y will be omitted from the list.
285     6 | MRSETS /MCGROUP NAME=$mygroup VARIABLES=a b x y.
286       |                                               ^"
287 ])
288 AT_CLEANUP
289
290 AT_SETUP([MRSETS variables and VALUE must be same type])
291 AT_DATA([mrsets.sps],
292   [DEFINE_MRSETS_DATA
293 MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE=1.
294 MRSETS /MDGROUP NAME=$group2 VARIABLES=x y VALUE='abc'.
295 ])
296 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
297 "mrsets.sps:6.50: error: MRSETS: MDGROUP subcommand for group $group1 specifies a string VALUE, but the variables specified for this group are numeric.
298     6 | MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE=1.
299       |                                                  ^"
300
301 "mrsets.sps:7.50-7.54: error: MRSETS: MDGROUP subcommand for group $group2 specifies a string VALUE, but the variables specified for this group are numeric.
302     7 | MRSETS /MDGROUP NAME=$group2 VARIABLES=x y VALUE='abc'.
303       |                                                  ^~~~~"
304 ])
305 AT_CLEANUP
306
307 AT_SETUP([MRSETS VALUE must not be too wide])
308 AT_DATA([mrsets.sps],
309   [DEFINE_MRSETS_DATA
310 MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE='abc'.
311 ])
312 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
313 "mrsets.sps:6.50-6.54: error: MRSETS: VALUE string on MDGROUP subcommand for group $group1 is 3 bytes long, but it must be no longer than the narrowest variable in the group, which is a with a width of 1 bytes.
314     6 | MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE='abc'.
315       |                                                  ^~~~~"
316 ])
317 AT_CLEANUP
318
319 AT_SETUP([MRSETS LABEL and LABELSOURCE are exclusive])
320 AT_DATA([mrsets.sps],
321   [DEFINE_MRSETS_DATA
322 MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE='a'
323                 LABEL='label' LABELSOURCE=VARLABEL.
324 ])
325 AT_CHECK([pspp -O format=csv mrsets.sps], [0], [dnl
326 "mrsets.sps:7.31-7.50: warning: MRSETS: MDGROUP subcommand for group $group1 specifies LABELSOURCE=VARLABEL but not CATEGORYLABELS=COUNTEDVALUES.  Ignoring LABELSOURCE.
327     7 |                 LABEL='label' LABELSOURCE=VARLABEL.
328       |                               ^~~~~~~~~~~~~~~~~~~~"
329 ])
330 AT_CLEANUP
331
332 AT_SETUP([MRSETS DISPLAY or DELETE unknown group])
333 AT_DATA([mrsets.sps],
334   [DEFINE_MRSETS_DATA
335 [MRSETS /DISPLAY NAME=[$x].
336 MRSETS /DELETE NAME=[$y].
337 ]])
338 AT_CHECK([pspp -O format=csv mrsets.sps], [1], [dnl
339 "mrsets.sps:6.23-6.24: error: MRSETS: No multiple response set named $x.
340     6 | MRSETS /DISPLAY NAME=[[$x]].
341       |                       ^~"
342
343 "mrsets.sps:7.22-7.23: error: MRSETS: No multiple response set named $y.
344     7 | MRSETS /DELETE NAME=[[$y]].
345       |                      ^~"
346 ])
347 AT_CLEANUP