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