49d9c7b215a56f68fc014df6ae0d14b38d39f529
[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],
68   [mrsets.sps:25: 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
70 mrsets.sps:29: 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.
71
72 mrsets.sps:29: 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.
73
74 mrsets.sps:34: 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.
75
76 mrsets.sps:34: 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.
77
78 mrsets.sps:38: warning: MRSETS: MDGROUP subcommand for group $d specifies LABELSOURCE=VARLABEL but not CATEGORYLABELS=COUNTEDVALUES.  Ignoring LABELSOURCE.
79
80 "mrsets.sps:41: 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."
81
82 "mrsets.sps:42: 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."
83 ])
84
85 m4_define([MRSETS_DISPLAY_OUTPUT],
86   [Table: Multiple Response Sets
87 Name,Variables,Details
88 $a,"w
89 x
90 y
91 z
92 ","Multiple dichotomy set
93 Label: First multiple dichotomy group
94 Label source: Provided by user
95 Counted value: 5
96 Category label source: Variable labels
97 "
98 $b,"z
99 y
100 ","Multiple dichotomy set
101 Counted value: 123
102 Category label source: Value labels of counted value
103 "
104 $c,"w
105 x
106 y
107 z
108 ","Multiple dichotomy set
109 Label: duplicate variable label
110 Label source: First variable label among variables
111 Counted value: 1
112 Category label source: Value labels of counted value
113 "
114 $d,"a
115 b
116 c
117 d
118 ","Multiple dichotomy set
119 Counted value: `c'
120 Category label source: Variable labels
121 "
122 $e,"w
123 x
124 y
125 z
126 ","Multiple category set
127 Label: First multiple category group
128 "
129 $f,"a
130 b
131 c
132 d
133 ","Multiple category set
134 "
135 ])
136
137 AT_SETUP([MRSETS add, display, delete])
138 AT_DATA([mrsets.sps],
139   [DEFINE_MRSETS
140 [MRSETS
141     /DISPLAY NAME=[$a]
142     /DISPLAY NAME=ALL
143     /DELETE NAME=[$c]
144     /DISPLAY NAME=ALL
145     /DELETE NAME=ALL
146     /DISPLAY NAME=ALL.
147 ]])
148 AT_CHECK([pspp -O format=csv mrsets.sps], [0],
149   [DEFINE_MRSETS_OUTPUT
150 Table: Multiple Response Sets
151 Name,Variables,Details
152 $a,"w
153 x
154 y
155 z
156 ","Multiple dichotomy set
157 Label: First multiple dichotomy group
158 Label source: Provided by user
159 Counted value: 5
160 Category label source: Variable labels
161 "
162
163 MRSETS_DISPLAY_OUTPUT
164 Table: Multiple Response Sets
165 Name,Variables,Details
166 $a,"w
167 x
168 y
169 z
170 ","Multiple dichotomy set
171 Label: First multiple dichotomy group
172 Label source: Provided by user
173 Counted value: 5
174 Category label source: Variable labels
175 "
176 $b,"z
177 y
178 ","Multiple dichotomy set
179 Counted value: 123
180 Category label source: Value labels of counted value
181 "
182 $d,"a
183 b
184 c
185 d
186 ","Multiple dichotomy set
187 Counted value: `c'
188 Category label source: Variable labels
189 "
190 $e,"w
191 x
192 y
193 z
194 ","Multiple category set
195 Label: First multiple category group
196 "
197 $f,"a
198 b
199 c
200 d
201 ","Multiple category set
202 "
203
204 mrsets.sps:50: note: MRSETS: The active dataset dictionary does not contain any multiple response sets.
205 ])
206 AT_CLEANUP
207
208 AT_SETUP([MRSETS read and write])
209 AT_DATA([mrsets.sps],
210   [DEFINE_MRSETS
211 SAVE OUTFILE='mrsets.sav'.
212 ])
213 AT_CHECK([pspp -O format=csv mrsets.sps], [0], [DEFINE_MRSETS_OUTPUT])
214 AT_DATA([mrsets2.sps],
215   [GET FILE='mrsets.sav'.
216 MRSETS /DISPLAY NAME=ALL.
217 ])
218 AT_CHECK([pspp -O format=csv mrsets2.sps], [0], [MRSETS_DISPLAY_OUTPUT],
219   [], [hd mrsets.sav])
220 AT_CLEANUP
221
222 AT_SETUP([MRSETS names must begin with $])
223 AT_DATA([mrsets.sps],
224   [DEFINE_MRSETS_DATA
225 MRSETS /MCGROUP NAME=x.
226 ])
227 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
228   [mrsets.sps:6: error: MRSETS: x is not a valid name for a multiple response set.  Multiple response set names must begin with `$'.
229 ])
230 AT_CLEANUP
231
232 AT_SETUP([MRSETS must have at least 2 variables])
233 AT_DATA([mrsets.sps],
234   [DEFINE_MRSETS_DATA
235 MRSETS /MCGROUP NAME=$x VARIABLES=a.
236 ])
237 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
238   ["mrsets.sps:6: error: MRSETS: VARIABLES specified only variable a on MCGROUP, but at least two variables are required."
239 ])
240 AT_CLEANUP
241
242 AT_SETUP([MRSETS does not allow noninteger VALUE])
243 AT_DATA([mrsets.sps],
244   [DEFINE_MRSETS_DATA
245 MRSETS /MDGROUP VALUE=1.5.
246 ])
247 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
248   [mrsets.sps:6: error: MRSETS: Numeric VALUE must be an integer.
249 ])
250 AT_CLEANUP
251
252 AT_SETUP([MRSETS requires NAME to define a group])
253 AT_DATA([mrsets.sps],
254   [DEFINE_MRSETS_DATA
255 MRSETS /MCGROUP VARIABLES=a b c.
256 ])
257 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
258   [mrsets.sps:6.32: error: MRSETS: Syntax error at end of command: Required MCGROUP specification missing from NAME subcommand.
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],
268   [mrsets.sps:6.30: error: MRSETS: Syntax error at end of command: Required MCGROUP specification missing from VARIABLES subcommand.
269 ])
270 AT_CLEANUP
271
272 AT_SETUP([MRSETS variables must be same type])
273 AT_DATA([mrsets.sps],
274   [DEFINE_MRSETS_DATA
275 MRSETS /MCGROUP NAME=$mygroup VARIABLES=a b x y.
276 ])
277 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
278   [mrsets.sps:6: 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.
279
280 mrsets.sps:6: 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.
281 ])
282 AT_CLEANUP
283
284 AT_SETUP([MRSETS variables and VALUE must be same type])
285 AT_DATA([mrsets.sps],
286   [DEFINE_MRSETS_DATA
287 MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE=1.
288 MRSETS /MDGROUP NAME=$group2 VARIABLES=x y VALUE='abc'.
289 ])
290 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
291   ["mrsets.sps:6: error: MRSETS: MDGROUP subcommand for group $group1 specifies a string VALUE, but the variables specified for this group are numeric."
292
293 "mrsets.sps:7: error: MRSETS: MDGROUP subcommand for group $group2 specifies a string VALUE, but the variables specified for this group are numeric."
294 ])
295 AT_CLEANUP
296
297 AT_SETUP([MRSETS VALUE must not be too wide])
298 AT_DATA([mrsets.sps],
299   [DEFINE_MRSETS_DATA
300 MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE='abc'.
301 ])
302 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
303   ["mrsets.sps:6: 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."
304 ])
305 AT_CLEANUP
306
307 AT_SETUP([MRSETS LABEL and LABELSOURCE are exclusive])
308 AT_DATA([mrsets.sps],
309   [DEFINE_MRSETS_DATA
310 MRSETS /MDGROUP NAME=$group1 VARIABLES=a b VALUE='a'
311                 LABEL='label' LABELSOURCE=VARLABEL.
312 ])
313 AT_CHECK([pspp -O format=csv mrsets.sps], [0],
314   [mrsets.sps:7: warning: MRSETS: MDGROUP subcommand for group $group1 specifies LABELSOURCE=VARLABEL but not CATEGORYLABELS=COUNTEDVALUES.  Ignoring LABELSOURCE.
315 ])
316 AT_CLEANUP
317
318 AT_SETUP([MRSETS DISPLAY or DELETE unknown group])
319 AT_DATA([mrsets.sps],
320   [DEFINE_MRSETS_DATA
321 [MRSETS /DISPLAY NAME=[$x].
322 MRSETS /DELETE NAME=[$y].
323 ]])
324 AT_CHECK([pspp -O format=csv mrsets.sps], [1],
325   [mrsets.sps:6: error: MRSETS: No multiple response set named $x.
326
327 mrsets.sps:7: error: MRSETS: No multiple response set named $y.
328 ])
329 AT_CLEANUP