1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
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.
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.
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/>.
19 m4_define([PSPP_CHECK_MACRO_EXPANSION],
20 [AT_SETUP([macro expansion - $1])
21 AT_DATA([define.sps], [$2
27 AT_CHECK([pspp --testing-mode define.sps | sed '/^$/d'], [$6], [expout])
30 AT_SETUP([simple macro expansion])
31 AT_DATA([define.sps], [dnl
39 "a" "b" "c" 'a' 'b' 'c'.
45 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
50 "a" "b" "c" 'a' 'b' 'c'.
55 PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) positional argument],
56 [DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.],
63 note: unexpanded token "b"])
65 AT_SETUP([macro expansion with positional arguments])
66 AT_DATA([define.sps], [dnl
67 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
68 DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
69 DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE.
71 DEFINE !ce(!positional !charend('/')) ce (!1) !ENDDEFINE.
72 DEFINE !ce2(!positional !charend('(')
73 /!positional !charend(')'))
77 DEFINE !e(!positional !enclose('{','}')) e (!1) !ENDDEFINE.
79 DEFINE !cmd(!positional !cmdend) cmd(!1) !ENDDEFINE.
80 DEFINE !cmd2(!positional !cmdend
81 /!positional !tokens(1))
85 DEFINE !p(!positional !tokens(1)
86 /!positional !tokens(1)
87 /!positional !tokens(1))
92 !title "!TOKENS(1) argument."
97 !title "!TOKENS(2) argument."
101 !title "!CHAREND argument."
107 !title "Two !CHAREND arguments."
111 !title "!ENCLOSE argument."
116 !title "!CMDEND argument."
121 !title "Three !TOKENS(1) arguments."
125 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
126 "!TOKENS(1) argument."
134 note: unexpanded token "b"
136 "!TOKENS(2) argument."
142 note: unexpanded token "d"
154 "Two !CHAREND arguments."
174 "Three !TOKENS(1) arguments."
182 AT_SETUP([macro expansion with positional arguments - negative])
183 AT_DATA([define.sps], [dnl
184 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
185 DEFINE !p(!positional !tokens(1)
186 /!positional !tokens(1)
187 /!positional !tokens(1))
191 DEFINE !ce(!positional !charend('/')) ce(!1) !ENDDEFINE.
193 DEFINE !enc1(!positional !enclose('{', '}')) enc1(!1) !ENDDEFINE.
195 !title "Too few tokens for !TOKENS."
200 !title "Missing charend delimiter."
203 !title "Missing start delimiter."
206 !title "Missing end delimiter."
209 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
210 "Too few tokens for !TOKENS."
212 define.sps:13: error: DEBUG EXPAND: Unexpected end of command reading
213 argument !3 to macro !p.
215 note: unexpanded token "!p"
217 note: unexpanded token "a"
219 note: unexpanded token "b"
221 define.sps:14: error: DEBUG EXPAND: Unexpected end of command reading
222 argument !2 to macro !p.
224 note: unexpanded token "!p"
226 note: unexpanded token "a"
228 define.sps:15: error: DEBUG EXPAND: Unexpected end of command reading
229 argument !1 to macro !p.
231 note: unexpanded token "!p"
233 "Missing charend delimiter."
235 define.sps:18: error: DEBUG EXPAND: Unexpected end of command reading
236 argument !1 to macro !ce.
238 note: unexpanded token "!ce"
240 note: unexpanded token "a"
242 note: unexpanded token "b"
244 note: unexpanded token "c"
246 "Missing start delimiter."
248 define.sps:21: error: DEBUG EXPAND: Found `a' while expecting `{' reading
249 argument !1 to macro !enc1.
251 note: unexpanded token "!enc1"
253 note: unexpanded token "a"
255 note: unexpanded token "b"
257 note: unexpanded token "c"
259 "Missing end delimiter."
261 define.sps:24: error: DEBUG EXPAND: Unexpected end of command reading
262 argument !1 to macro !enc1.
264 note: unexpanded token "!enc1"
266 note: unexpanded token "{"
268 note: unexpanded token "a"
270 note: unexpanded token "b"
272 note: unexpanded token "c"
276 PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) keyword argument],
277 [DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.],
283 note: unexpanded token "y"
286 PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) keyword argument - negative],
287 [DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.],
290 define.sps:3: error: DEBUG EXPAND: Found `.' while expecting `=' reading
291 argument !arg1 to macro !k.
292 note: unexpanded token "!k"
293 note: unexpanded token "arg1"
294 define.sps:4: error: DEBUG EXPAND: Unexpected end of command reading argument !
296 note: unexpanded token "!k"
297 note: unexpanded token "arg1"
298 note: unexpanded token "="], [1])
300 PSPP_CHECK_MACRO_EXPANSION([!CHAREND('/') keyword arguments], [dnl
301 DEFINE !k(arg1 = !CHAREND('/')
302 /arg2 = !CHAREND('/'))
314 PSPP_CHECK_MACRO_EXPANSION([!CHAREND('/') keyword arguments - negative], [dnl
315 DEFINE !k(arg1 = !CHAREND('/')
316 /arg2 = !CHAREND('/'))
323 [define.sps:6: error: DEBUG EXPAND: Found `.' while expecting `=' reading
324 argument !arg1 to macro !k.
325 note: unexpanded token "!k"
326 note: unexpanded token "arg1"
327 define.sps:7: error: DEBUG EXPAND: Unexpected end of command reading argument !
329 note: unexpanded token "!k"
330 note: unexpanded token "arg1"
331 note: unexpanded token "="
332 define.sps:8: error: DEBUG EXPAND: Unexpected end of command reading argument !
334 note: unexpanded token "!k"
335 note: unexpanded token "arg1"
336 note: unexpanded token "="
337 note: unexpanded token "x"
338 define.sps:9: error: DEBUG EXPAND: Unexpected end of command reading argument !
340 note: unexpanded token "!k"
341 note: unexpanded token "arg1"
342 note: unexpanded token "="
343 note: unexpanded token "x"
344 note: unexpanded token "/"
345 note: unexpanded token "arg2"
346 note: unexpanded token "="
347 note: unexpanded token "y"])