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