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
31 AT_SETUP([simple macro expansion])
32 AT_DATA([define.sps], [dnl
40 "a" "b" "c" 'a' 'b' 'c'.
46 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
51 "a" "b" "c" 'a' 'b' 'c'.
56 PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) positional argument],
57 [DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.],
64 note: unexpanded token "b"])
66 AT_SETUP([macro expansion with positional arguments])
67 AT_DATA([define.sps], [dnl
68 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
69 DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
70 DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE.
72 DEFINE !ce(!positional !charend('/')) ce (!1) !ENDDEFINE.
73 DEFINE !ce2(!positional !charend('(')
74 /!positional !charend(')'))
78 DEFINE !e(!positional !enclose('{','}')) e (!1) !ENDDEFINE.
80 DEFINE !cmd(!positional !cmdend) cmd(!1) !ENDDEFINE.
81 DEFINE !cmd2(!positional !cmdend
82 /!positional !tokens(1))
86 DEFINE !p(!positional !tokens(1)
87 /!positional !tokens(1)
88 /!positional !tokens(1))
93 !title "!TOKENS(1) argument."
98 !title "!TOKENS(2) argument."
102 !title "!CHAREND argument."
108 !title "Two !CHAREND arguments."
112 !title "!ENCLOSE argument."
117 !title "!CMDEND argument."
122 !title "Three !TOKENS(1) arguments."
126 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
127 "!TOKENS(1) argument."
135 note: unexpanded token "b"
137 "!TOKENS(2) argument."
143 note: unexpanded token "d"
155 "Two !CHAREND arguments."
175 "Three !TOKENS(1) arguments."
183 AT_SETUP([macro expansion with positional arguments - negative])
184 AT_DATA([define.sps], [dnl
185 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
186 DEFINE !p(!positional !tokens(1)
187 /!positional !tokens(1)
188 /!positional !tokens(1))
192 DEFINE !ce(!positional !charend('/')) ce(!1) !ENDDEFINE.
194 DEFINE !enc1(!positional !enclose('{', '}')) enc1(!1) !ENDDEFINE.
196 !title "Too few tokens for !TOKENS."
201 !title "Missing charend delimiter."
204 !title "Missing start delimiter."
207 !title "Missing end delimiter."
210 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
211 "Too few tokens for !TOKENS."
213 define.sps:13: error: DEBUG EXPAND: Unexpected end of command reading
214 argument !3 to macro !p.
216 note: unexpanded token "!p"
218 note: unexpanded token "a"
220 note: unexpanded token "b"
222 define.sps:14: error: DEBUG EXPAND: Unexpected end of command reading
223 argument !2 to macro !p.
225 note: unexpanded token "!p"
227 note: unexpanded token "a"
229 define.sps:15: error: DEBUG EXPAND: Unexpected end of command reading
230 argument !1 to macro !p.
232 note: unexpanded token "!p"
234 "Missing charend delimiter."
236 define.sps:18: error: DEBUG EXPAND: Unexpected end of command reading
237 argument !1 to macro !ce.
239 note: unexpanded token "!ce"
241 note: unexpanded token "a"
243 note: unexpanded token "b"
245 note: unexpanded token "c"
247 "Missing start delimiter."
249 define.sps:21: error: DEBUG EXPAND: Found `a' while expecting `{' reading
250 argument !1 to macro !enc1.
252 note: unexpanded token "!enc1"
254 note: unexpanded token "a"
256 note: unexpanded token "b"
258 note: unexpanded token "c"
260 "Missing end delimiter."
262 define.sps:24: error: DEBUG EXPAND: Unexpected end of command reading
263 argument !1 to macro !enc1.
265 note: unexpanded token "!enc1"
267 note: unexpanded token "{"
269 note: unexpanded token "a"
271 note: unexpanded token "b"
273 note: unexpanded token "c"
277 PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) keyword argument],
278 [DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.],
284 note: unexpanded token "y"