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 nGeneral 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 AT_SETUP([simple macro expansion])
20 AT_DATA([define.sps], [dnl
28 "a" "b" "c" 'a' 'b' 'c'.
34 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
39 "a" "b" "c" 'a' 'b' 'c'.
44 AT_SETUP([redefining a macro])
45 AT_DATA([define.sps], [dnl
46 DEFINE !macro() 0 !ENDDEFINE.
47 DEFINE !macro() 1 !ENDDEFINE.
51 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
56 AT_SETUP([macro expansion - one !TOKENS(1) positional argument])
58 AT_DATA([define.sps], [dnl
59 DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE.
65 AT_CAPTURE_FILE([define.sps])
66 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
73 note: unexpanded token "b"
77 AT_SETUP([macro expansion with positional arguments])
78 AT_DATA([define.sps], [dnl
79 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
80 DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
81 DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE.
83 DEFINE !ce(!positional=!charend('/')) ce (!1) !ENDDEFINE.
84 DEFINE !ce2(!positional=!charend('(')
85 /!positional !charend(')'))
89 DEFINE !e(!positional !enclose('{','}')) e (!1) !ENDDEFINE.
91 DEFINE !cmd(!positional !cmdend) cmd(!1) !ENDDEFINE.
92 DEFINE !cmd2(!positional !cmdend
93 /!positional !tokens(1))
97 DEFINE !p(!positional !tokens(1)
98 /!positional !tokens(1)
99 /!positional !tokens(1))
104 !title "!TOKENS(1) argument."
109 !title "!TOKENS(2) argument."
113 !title "!CHAREND argument."
119 !title "Two !CHAREND arguments."
123 !title "!ENCLOSE argument."
128 !title "!CMDEND argument."
133 !title "Three !TOKENS(1) arguments."
137 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
138 "!TOKENS(1) argument."
146 note: unexpanded token "b"
148 "!TOKENS(2) argument."
154 note: unexpanded token "d"
166 "Two !CHAREND arguments."
186 note: unexpanded token "7"
188 "Three !TOKENS(1) arguments."
192 p(1, -2, -3) (1 -2 -3)
196 AT_SETUP([macro call missing positional !TOKENS arguments])
197 AT_KEYWORDS([TOKENS])
198 AT_DATA([define.sps], [dnl
199 DEFINE !p(!positional !tokens(1) !default(x)
200 /!positional !tokens(1) !default(y)
201 /!positional !tokens(1) !default(z))
210 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
221 AT_SETUP([macro call incomplete positional !TOKENS arguments])
222 AT_KEYWORDS([TOKENS])
223 AT_DATA([define.sps], [dnl
224 DEFINE !p(!positional !tokens(2) !default(x)
225 /!positional !tokens(2) !default(y)
226 /!positional !tokens(2) !default(z))
230 !p a1 a2 b1 b2 c1 c2.
238 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
239 (a1 a2, b1 b2, c1 c2)
241 define.sps:8.18: error: DEBUG EXPAND: Reached end of command expecting 1 more
242 token in argument !3 to macro !p.
248 define.sps:10.12: error: DEBUG EXPAND: Reached end of command expecting 1 more
249 token in argument !2 to macro !p.
255 define.sps:12.6: error: DEBUG EXPAND: Reached end of command expecting 1 more
256 token in argument !1 to macro !p.
264 AT_SETUP([macro call empty positional !CHAREND arguments])
265 AT_KEYWORDS([CHAREND])
266 AT_DATA([define.sps], [dnl
267 DEFINE !p(!positional !charend(',') !default(x)
268 /!positional !charend(';') !default(y)
269 /!positional !charend(':') !default(z))
282 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
301 AT_SETUP([macro call missing positional !CHAREND arguments])
302 AT_DATA([define.sps], [dnl
303 DEFINE !p(!positional !charend(',') !default(x)
304 /!positional !charend(';') !default(y)
305 /!positional !charend(':') !default(z))
320 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
339 AT_SETUP([macro call incomplete positional !CHAREND arguments])
340 AT_KEYWORDS([CHAREND])
341 AT_DATA([define.sps], [dnl
342 DEFINE !p(!positional !charend(',') !default(x)
343 /!positional !charend(';') !default(y)
344 /!positional !charend(':') !default(z))
356 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
359 define.sps:8.9: error: DEBUG EXPAND: Reached end of command expecting ":" in
360 argument !3 to macro !p.
366 define.sps:10.7: error: DEBUG EXPAND: Reached end of command expecting ";" in
367 argument !2 to macro !p.
373 define.sps:12.5: error: DEBUG EXPAND: Reached end of command expecting "," in
374 argument !1 to macro !p.
382 AT_SETUP([macro call missing positional !ENCLOSE arguments])
383 AT_KEYWORDS([ENCLOSE])
384 AT_DATA([define.sps], [dnl
385 DEFINE !p(!positional !enclose('(',')') !default(x)
386 /!positional !enclose('<','>') !default(y)
387 /!positional !enclose('{','}') !default(z))
396 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
407 AT_SETUP([macro call incomplete positional !ENCLOSE arguments])
408 AT_KEYWORDS([ENCLOSE])
409 AT_DATA([define.sps], [dnl
410 DEFINE !p(!positional !enclose('(',')') !default(x)
411 /!positional !enclose('<','>') !default(y)
412 /!positional !enclose('{','}') !default(z))
427 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
430 define.sps:8.12: error: DEBUG EXPAND: Reached end of command expecting "}" in
431 argument !3 to macro !p.
435 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "}" in
436 argument !3 to macro !p.
442 define.sps:11.9: error: DEBUG EXPAND: Reached end of command expecting ">" in
443 argument !2 to macro !p.
447 define.sps:12.8: error: DEBUG EXPAND: Reached end of command expecting ">" in
448 argument !2 to macro !p.
454 define.sps:14.6: error: DEBUG EXPAND: Reached end of command expecting ")" in
455 argument !1 to macro !p.
459 define.sps:15.5: error: DEBUG EXPAND: Reached end of command expecting ")" in
460 argument !1 to macro !p.
468 AT_SETUP([keyword macro argument name with ! prefix])
469 AT_DATA([define.sps], [dnl
470 DEFINE !macro(!x !TOKENS(1).
472 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
473 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `!x': Keyword macro parameter must be named in definition without ""!"" prefix."
477 AT_SETUP([reserved macro keyword argument name])
478 AT_DATA([define.sps], [dnl
479 DEFINE !macro(if=!TOKENS(1).
481 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
482 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `if': Cannot use macro keyword ""if"" as an argument name."
486 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument])
487 AT_KEYWORDS([TOKENS])
488 AT_DATA([define.sps], [dnl
489 DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.
495 AT_CAPTURE_FILE([define.sps])
496 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
501 note: unexpanded token "y"
507 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative])
508 AT_KEYWORDS([TOKENS])
509 AT_DATA([define.sps], [dnl
510 DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE.
515 AT_CAPTURE_FILE([define.sps])
516 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
517 define.sps:3.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
518 argument !arg1 to macro !k.
522 define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more
523 token in argument !arg1 to macro !k.
529 AT_SETUP([macro expansion - !CHAREND keyword arguments])
530 AT_KEYWORDS([CHAREND])
531 AT_DATA([define.sps], [dnl
532 DEFINE !k(arg1 = !CHAREND('/')
533 /arg2 = !CHAREND('/'))
542 AT_CAPTURE_FILE([define.sps])
543 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
554 AT_SETUP([macro expansion - !CHAREND keyword arguments - negative])
555 AT_KEYWORDS([CHAREND])
556 AT_DATA([define.sps], [dnl
557 DEFINE !k(arg1 = !CHAREND('/')
558 /arg2 = !CHAREND('/'))
567 AT_CAPTURE_FILE([define.sps])
568 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
569 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
570 argument !arg1 to macro !k.
574 define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in
575 argument !arg1 to macro !k.
579 define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in
580 argument !arg1 to macro !k.
584 define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in
585 argument !arg2 to macro !k.
591 AT_SETUP([macro expansion - !ENCLOSE keyword arguments])
592 AT_KEYWORDS([ENCLOSE])
593 AT_DATA([define.sps], [dnl
594 DEFINE !k(arg1 = !ENCLOSE('(',')')
595 /arg2 = !ENCLOSE('{','}'))
599 !k arg1=(x) arg2={y}.
604 AT_CAPTURE_FILE([define.sps])
605 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
616 AT_SETUP([macro expansion - !ENCLOSE keyword arguments - negative])
617 AT_KEYWORDS([ENCLOSE])
618 AT_DATA([define.sps], [dnl
619 DEFINE !k(arg1 = !ENCLOSE('(',')')
620 /arg2 = !ENCLOSE('{','}'))
633 AT_CAPTURE_FILE([define.sps])
634 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
635 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
636 argument !arg1 to macro !k.
640 define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading
641 argument !arg1 to macro !k.
645 define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading
646 argument !arg1 to macro !k.
650 note: unexpanded token "x"
652 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "@:}@" in
653 argument !arg1 to macro !k.
657 define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading
658 argument !arg2 to macro !k.
662 define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading
663 argument !arg2 to macro !k.
667 define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading
668 argument !arg2 to macro !k.
672 note: unexpanded token "y"
674 define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading
675 argument !arg2 to macro !k.
679 note: unexpanded token "@{:@"
681 note: unexpanded token "y"
685 dnl Keep this test in sync with the examples for !BLANKS in the manual.
686 AT_SETUP([macro expansion - !BLANKS])
687 AT_KEYWORDS([BLANKS])
688 AT_DATA([define.sps], [dnl
702 AT_CAPTURE_FILE([define.sps])
703 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
715 dnl Keep this test in sync with the examples for !CONCAT in the manual.
716 AT_SETUP([macro expansion - !CONCAT])
717 AT_KEYWORDS([CONCAT])
718 AT_DATA([define.sps], [dnl
732 AT_CAPTURE_FILE([define.sps])
733 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
745 dnl Keep this test in sync with the examples for !EVAL in the manual.
746 AT_SETUP([macro expansion - !EVAL])
748 AT_DATA([define.sps], [dnl
749 DEFINE !vars() a b c !ENDDEFINE.
755 !QUOTE(!EVAL(!vars)).
758 DEFINE !e2(!positional !enclose('(',')'))
768 AT_CAPTURE_FILE([define.sps])
769 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
782 dnl Keep this test in sync with the examples for !HEAD in the manual.
783 AT_SETUP([macro expansion - !HEAD])
785 AT_DATA([define.sps], [dnl
795 AT_CAPTURE_FILE([define.sps])
796 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
804 dnl Keep this test in sync with the examples for !TAIL in the manual.
805 AT_SETUP([macro expansion - !TAIL])
807 AT_DATA([define.sps], [dnl
817 AT_CAPTURE_FILE([define.sps])
818 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
826 dnl Keep this test in sync with the examples for !INDEX in the manual.
827 AT_SETUP([macro expansion - !INDEX])
829 AT_DATA([define.sps], [dnl
833 !INDEX(banana, apple).
834 !INDEX("banana", nan).
835 !INDEX("banana", "nan").
836 !INDEX(!UNQUOTE("banana"), !UNQUOTE("nan")).
841 AT_CAPTURE_FILE([define.sps])
842 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
852 dnl Keep this test in sync with the examples for !LENGTH in the manual.
853 AT_SETUP([macro expansion - !LENGTH])
854 AT_KEYWORDS([LENGTH])
855 AT_DATA([define.sps], [dnl
864 !LENGTH(!UNQUOTE("xyzzy")).
865 !LENGTH(!UNQUOTE("xy""zzy")).
868 DEFINE !la(!positional !enclose('(',')'))
876 AT_CAPTURE_FILE([define.sps])
877 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
895 dnl Keep this test in sync with the examples for !NULL in the manual.
896 AT_SETUP([macro expansion - !NULL])
898 AT_DATA([define.sps], [dnl
906 AT_CAPTURE_FILE([define.sps])
907 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
913 dnl Keep this test in sync with the examples for !QUOTE and !UNQUOTE in the manual.
914 AT_SETUP([macro expansion - !QUOTE and !UNQUOTE])
915 AT_KEYWORDS([QUOTE UNQUOTE])
916 AT_DATA([define.sps], [dnl
917 DEFINE !q(!POS !CMDEND)
930 !QUOTE(!UNQUOTE(123.0)).
931 !QUOTE(!UNQUOTE( 123 )).
932 !QUOTE(!UNQUOTE('a b c')).
933 !QUOTE(!UNQUOTE("a b c")).
934 !QUOTE(!UNQUOTE(!1)).
939 AT_CAPTURE_FILE([define.sps])
940 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
961 dnl Keep this test in sync with the examples for !SUBSTR in the manual.
962 AT_SETUP([macro expansion - !SUBSTR])
963 AT_KEYWORDS([SUBSTR])
964 AT_DATA([define.sps], [dnl
967 !SUBSTR(banana, 3, 3).
968 !SUBSTR("banana", 1, 3).
969 !SUBSTR(!UNQUOTE("banana"), 3).
970 !SUBSTR("banana", 3, 3).
971 !SUBSTR(banana, 3, 0).
972 !SUBSTR(banana, 3, 10).
973 !SUBSTR(banana, 10, 3).
978 AT_CAPTURE_FILE([define.sps])
979 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
980 define.sps:1-10: At `"ba' in the expansion of `!s',dnl "
982 define.sps:12.1-12.2: error: DEBUG EXPAND: Unterminated string constant.
995 dnl Keep this test in sync with the examples for !UPCASE in the manual.
996 AT_SETUP([macro expansion - !UPCASE])
997 AT_KEYWORDS([UPCASE])
998 AT_DATA([define.sps], [dnl
1008 AT_CAPTURE_FILE([define.sps])
1009 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1017 dnl !* is implemented separately inside and outside function arguments
1018 dnl so this test makes sure to include both.
1019 AT_SETUP([macro expansion - !*])
1020 AT_DATA([define.sps], [dnl
1021 DEFINE !m(!POSITIONAL !TOKENS(1)
1022 /!POSITIONAL !TOKENS(1))
1033 AT_CAPTURE_FILE([define.sps])
1034 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1035 123 b / 5 / 3 b / '123 b'.
1037 2 3 / 3 / 3 / '2 3'.
1039 '' 'b' / 6 / 'b' / ''''' ''b'''.
1043 AT_SETUP([macro maximum nesting level (MNEST)])
1044 AT_KEYWORDS([MNEST])
1045 AT_DATA([define.sps], [dnl
1051 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1052 "define.sps:1-3: In the expansion of `!macro',
1053 define.sps:1-3: inside the expansion of `!macro',
1054 define.sps:1-3: inside the expansion of `!macro',
1055 define.sps:1-3: inside the expansion of `!macro',
1056 define.sps:1-3: inside the expansion of `!macro',
1057 define.sps:1-3: inside the expansion of `!macro',
1058 define.sps:1-3: inside the expansion of `!macro',
1059 define.sps:1-3: inside the expansion of `!macro',
1060 define.sps:1-3: inside the expansion of `!macro',
1061 define.sps:1-3: inside the expansion of `!macro',
1062 define.sps:1-3: inside the expansion of `!macro',
1063 define.sps:1-3: inside the expansion of `!macro',
1064 define.sps:1-3: inside the expansion of `!macro',
1065 define.sps:1-3: inside the expansion of `!macro',
1066 define.sps:1-3: inside the expansion of `!macro',
1067 define.sps:1-3: inside the expansion of `!macro',
1068 define.sps:1-3: inside the expansion of `!macro',
1069 define.sps:1-3: inside the expansion of `!macro',
1070 define.sps:1-3: inside the expansion of `!macro',
1071 define.sps:1-3: inside the expansion of `!macro',
1072 define.sps:1-3: inside the expansion of `!macro',
1073 define.sps:1-3: inside the expansion of `!macro',
1074 define.sps:1-3: inside the expansion of `!macro',
1075 define.sps:1-3: inside the expansion of `!macro',
1076 define.sps:1-3: inside the expansion of `!macro',
1077 define.sps:1-3: inside the expansion of `!macro',
1078 define.sps:1-3: inside the expansion of `!macro',
1079 define.sps:1-3: inside the expansion of `!macro',
1080 define.sps:1-3: inside the expansion of `!macro',
1081 define.sps:1-3: inside the expansion of `!macro',
1082 define.sps:1-3: inside the expansion of `!macro',
1083 define.sps:1-3: inside the expansion of `!macro',
1084 define.sps:1-3: inside the expansion of `!macro',
1085 define.sps:1-3: inside the expansion of `!macro',
1086 define.sps:1-3: inside the expansion of `!macro',
1087 define.sps:1-3: inside the expansion of `!macro',
1088 define.sps:1-3: inside the expansion of `!macro',
1089 define.sps:1-3: inside the expansion of `!macro',
1090 define.sps:1-3: inside the expansion of `!macro',
1091 define.sps:1-3: inside the expansion of `!macro',
1092 define.sps:1-3: inside the expansion of `!macro',
1093 define.sps:1-3: inside the expansion of `!macro',
1094 define.sps:1-3: inside the expansion of `!macro',
1095 define.sps:1-3: inside the expansion of `!macro',
1096 define.sps:1-3: inside the expansion of `!macro',
1097 define.sps:1-3: inside the expansion of `!macro',
1098 define.sps:1-3: inside the expansion of `!macro',
1099 define.sps:1-3: inside the expansion of `!macro',
1100 define.sps:1-3: inside the expansion of `!macro',
1101 define.sps:1-3: inside the expansion of `!macro',
1102 define.sps:1-3: inside the expansion of `!macro',
1103 define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.)"
1105 define.sps:4.1-4.6: error: Syntax error at `!macro' (in expansion of `!macro'): expecting command name.
1109 AT_SETUP([macro !IF condition])
1112 '!eq !ne !lt !gt !le !ge' \
1116 AS_BOX([$operators])
1117 cat > define.sps <<EOF
1118 DEFINE !test(!positional !tokens(1))
1119 !if (!1 $1 1) !then true !else false !ifend
1120 !if (!1 $2 1) !then true !else false !ifend
1121 !if (!1 $3 1) !then true !else false !ifend
1122 !if (!1 $4 1) !then true !else false !ifend
1123 !if (!1 $5 1) !then true !else false !ifend
1124 !if (!1 $6 1) !then true !else false !ifend.
1133 AT_CAPTURE_FILE([define.sps])
1134 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1135 false true true false true false.
1137 true false false false true true.
1139 false true false true false true.
1141 true false false false true true.
1143 false true false true false true.
1148 AT_SETUP([macro !IF condition -- case sensitivity])
1151 '!eq !ne !lt !gt !le !ge' \
1155 AS_BOX([$operators])
1156 cat > define.sps <<EOF
1157 DEFINE !test(!positional !tokens(1))
1158 !if (!1 $1 a) !then true !else false !ifend
1159 !if (!1 $1 A) !then true !else false !ifend
1160 !if (!1 $2 a) !then true !else false !ifend
1161 !if (!1 $2 A) !then true !else false !ifend
1162 !if (!1 $3 a) !then true !else false !ifend
1163 !if (!1 $3 A) !then true !else false !ifend
1164 !if (!1 $4 a) !then true !else false !ifend
1165 !if (!1 $4 A) !then true !else false !ifend
1166 !if (!1 $5 a) !then true !else false !ifend
1167 !if (!1 $5 A) !then true !else false !ifend
1168 !if (!1 $6 a) !then true !else false !ifend
1169 !if (!1 $6 A) !then true !else false !ifend
1170 !if (!1 $1 !null) !then true !else false !ifend
1171 !if (!1 $2 !null) !then true !else false !ifend.
1179 AT_CAPTURE_FILE([define.sps])
1180 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1181 true false false true false false false true true false true true false true.
1183 false true true false true false false false true true false true false true.
1185 false false true true false false true true false false true true false true.
1187 false false true true true false false true true false false true false true.
1192 AT_SETUP([macro !IF condition -- logical operators])
1199 AS_BOX([$operators])
1200 cat > define.sps <<EOF
1201 DEFINE !test_binary(!positional !tokens(1)/!positional !tokens(1))
1202 !if !1 $1 !2 !then true !else false !ifend
1203 !if !1 $2 !2 !then true !else false !ifend.
1206 DEFINE !test_unary(!positional !tokens(1))
1207 !if $3 !1 !then true !else false !ifend.
1211 ((not A) and B) or C
1214 DEFINE !test_prec(!pos !tokens(1)/!pos !tokens(1)/!pos !tokens(1))
1215 !if $3 !1 $1 !2 $2 !3 !then true !else false !ifend
1216 !if $3 (!1 $1 !2) $2 !3 !then true !else false !ifend
1217 !if $3 !1 $1 (!2 $2 !3) !then true !else false !ifend
1227 !test_prec 0 0 0 !test_prec 0 0 1 !test_prec 0 1 0 !test_prec 0 1 1.
1228 !test_prec 1 0 0 !test_prec 1 0 1 !test_prec 1 1 0 !test_prec 1 1 1.
1230 AT_CAPTURE_FILE([define.sps])
1231 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1257 AT_SETUP([macro !LET])
1259 AT_DATA([define.sps], [dnl
1260 DEFINE !macro(!POS !CMDEND)
1261 !LET !v1 = !CONCAT('x',!1,'y')
1262 !LET !v2 = !QUOTE(!v1)
1263 !LET !v3 = (!LENGTH(!1) = 1)
1264 !LET !v4 = (!SUBSTR(!1, 3) = !NULL)
1275 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1293 AT_SETUP([macro indexed !DO])
1294 AT_KEYWORDS([index do])
1295 AT_DATA([define.sps], [dnl
1296 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1298 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1299 !DO !var = !1 !TO !2 !var !DOEND.
1302 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1303 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1307 !title "increasing".
1314 !title "decreasing".
1321 !title "non-integer".
1324 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1355 AT_SETUP([macro !DO invalid variable names])
1356 AT_KEYWORDS([index do])
1357 AT_DATA([define.sps], [dnl
1358 DEFINE !for(x=!TOKENS(1) / y=!TOKENS(1))
1359 !DO !x = !x !TO !y !var !DOEND.
1362 DEFINE !for2(x=!TOKENS(1) / y=!TOKENS(1))
1363 !DO !noexpand = !x !TO !y !var !DOEND.
1370 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1371 define.sps:1-3: At `!x' in the expansion of `!for',
1372 define.sps:10.1-10.12: error: DEBUG EXPAND: Cannot use argument name or macro
1373 keyword as !DO variable.
1375 !DO 1 = 1 !TO 5 !var !DOEND.
1377 define.sps:5-7: At `!noexpand' in the expansion of `!for2',
1378 define.sps:11.1-11.13: error: DEBUG EXPAND: Cannot use argument name or macro
1379 keyword as !DO variable.
1381 !DO !noexpand = 1 !TO 5 !var !DOEND.
1385 AT_SETUP([macro indexed !DO reaches MITERATE])
1386 AT_KEYWORDS([index do])
1387 AT_DATA([define.sps], [dnl
1388 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1390 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1391 !DO !var = !1 !TO !2 !var !DOEND.
1394 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1395 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1400 !title "increasing".
1407 !title "decreasing".
1414 !title "non-integer".
1417 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1420 In the expansion of `!DO',
1421 define.sps:3-5: inside the expansion of `!for',
1422 define.sps:14.1-14.8: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1423 number of iterations 3. (Use SET MITERATE to change the limit.)
1427 In the expansion of `!DO',
1428 define.sps:7-9: inside the expansion of `!forby',
1429 define.sps:15.1-15.12: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1430 number of iterations 3. (Use SET MITERATE to change the limit.)
1446 In the expansion of `!DO',
1447 define.sps:7-9: inside the expansion of `!forby',
1448 define.sps:23.1-23.13: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1449 number of iterations 3. (Use SET MITERATE to change the limit.)
1463 AT_SETUP([!BREAK with macro indexed !DO])
1464 AT_KEYWORDS([index do break])
1465 AT_DATA([define.sps], [dnl
1466 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1468 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1469 !DO !var = !1 !TO !2
1485 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1490 AT_SETUP([macro list !DO])
1491 AT_KEYWORDS([index do])
1492 AT_DATA([define.sps], [dnl
1493 DEFINE !for(!POS !CMDEND)
1494 (!DO !i !IN (!1) (!i) !DOEND).
1499 !for 'foo bar baz quux'.
1502 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1505 ( (foo) (bar) (baz) (quux) ).
1511 AT_SETUP([macro list !DO reaches MITERATE])
1512 AT_KEYWORDS([index do])
1513 AT_DATA([define.sps], [dnl
1514 DEFINE !for(!POS !CMDEND)
1515 (!DO !i !IN (!1) (!i) !DOEND).
1521 !for 'foo bar baz quux'.
1524 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1525 In the expansion of `!DO',
1526 define.sps:1-3: inside the expansion of `!for',
1527 define.sps:7.1-7.10: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1528 number of iterations 2. (Use SET MITERATE to change the limit.)
1532 In the expansion of `!DO',
1533 define.sps:1-3: inside the expansion of `!for',
1534 define.sps:8.1-8.23: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1535 number of iterations 2. (Use SET MITERATE to change the limit.)
1543 AT_SETUP([!BREAK with macro list !DO])
1544 AT_KEYWORDS([index break do])
1545 AT_DATA([define.sps], [dnl
1546 DEFINE !for(!POS !TOKENS(1) / !POS !CMDEND)
1562 !for baz 'foo bar baz quux'.
1565 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1568 ( (foo), (bar), (baz)x).
1574 AT_SETUP([macro !LET])
1575 AT_DATA([define.sps], [dnl
1576 DEFINE !macro(!pos !enclose('(',')'))
1587 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl
1594 AT_SETUP([macro !LET invalid variable names])
1595 AT_DATA([define.sps], [dnl
1596 DEFINE !macro(x=!tokens(1))
1608 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [1], [dnl
1609 "define.sps:1-3: At `!x' in the expansion of `!macro',
1610 define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable."
1614 "define.sps:5-7: At `!do' in the expansion of `!macro2',
1615 define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable."
1617 "define.sps:5-7: At `=' in the expansion of `!macro2',
1618 define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO."
1624 AT_SETUP([BEGIN DATA inside a macro])
1625 AT_DATA([define.sps], [dnl
1627 DATA LIST NOTABLE /x 1.
1638 AT_CHECK([pspp define.sps -O format=csv], [0], [dnl
1647 AT_SETUP([TITLE and SUBTITLE with macros])
1648 AT_KEYWORDS([macro])
1649 for command in TITLE SUBTITLE; do
1650 cat >title.sps <<EOF
1651 DEFINE !paste(!POS !TOKENS(1) / !POS !TOKENS(1))
1654 $command prefix !paste foo bar suffix.
1658 title.sps:5: note: SHOW: $command is prefix foobar suffix.
1660 AT_CHECK([pspp -O format=csv title.sps], [0], [expout])
1664 AT_SETUP([error message within macro expansion])
1665 AT_DATA([define.sps], [dnl
1666 DEFINE !vars(!POS !TOKENS(1)) a b C !ENDDEFINE.
1667 DATA LIST NOTABLE /a b 1-2.
1668 COMPUTE x = !vars x.
1670 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1671 define.sps:3.13-3.19: error: COMPUTE: Syntax error at `b' (in expansion of `!vars x'): expecting end of command.
1675 dnl A macro with keyword arguments needs a token of lookahead
1676 dnl to find out whether another keyword is present. Test that
1677 dnl this special case works OK.
1678 AT_SETUP([macro calls in each others' lookahead])
1679 AT_DATA([define.sps], [dnl
1680 DEFINE !k(x=!DEFAULT(0) !TOKENS(1)/y=!DEFAULT(0) !TOKENS(1))
1690 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1702 AT_SETUP([bad token in macro body])
1703 AT_DATA([define.sps], [dnl
1708 AT_CHECK([pspp define.sps], [1], [dnl
1709 define.sps:3: error: DEFINE: String of hex digits has 3 characters, which is
1710 not a multiple of 2.
1714 AT_SETUP([macro name overlaps with macro function name])
1715 dnl !len is short for macro function !LENGTH. PSPP used to
1716 dnl reject the following with "`(' expected following !LENGTH".
1717 dnl Now PSPP only consider macro functions when the name is
1718 dnl followed by '('.
1719 AT_DATA([define.sps], [dnl
1720 DEFINE !len() 5 !ENDDEFINE.
1721 DEFINE !x() !eval(!len) !ENDDEFINE.
1725 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1730 AT_SETUP([generic macro function syntax errors])
1731 AT_DATA([define.sps], [dnl
1734 DEFINE !c() !SUBSTR(1x) !ENDDEFINE.
1735 DEFINE !d() !SUBSTR(1 !ENDDEFINE.
1736 DEFINE !narg_blanks() !BLANKS() !ENDDEFINE.
1737 DEFINE !narg_concat() !CONCAT() !ENDDEFINE.
1738 DEFINE !narg_eval() !EVAL() !ENDDEFINE.
1739 DEFINE !narg_head() !HEAD() !ENDDEFINE.
1740 DEFINE !narg_index() !INDEX() !ENDDEFINE.
1741 DEFINE !narg_length() !LENGTH() !ENDDEFINE.
1742 DEFINE !narg_null() !NULL() !ENDDEFINE.
1743 DEFINE !narg_quote() !QUOTE() !ENDDEFINE.
1744 DEFINE !narg_substr() !SUBSTR() !ENDDEFINE.
1745 DEFINE !narg_tail() !TAIL() !ENDDEFINE.
1746 DEFINE !narg_unquote() !UNQUOTE() !ENDDEFINE.
1747 DEFINE !narg_upcase() !UPCASE() !ENDDEFINE.
1767 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1768 define.sps:3: At `x' in the expansion of `!c',
1769 define.sps:20.1-20.2: error: DEBUG EXPAND: `,' or `@:}@' expected in call to macro
1774 define.sps:4: In the expansion of `!d',
1775 define.sps:21.1-21.2: error: DEBUG EXPAND: Missing `@:}@' in call to macro
1780 define.sps:5: In the expansion of `!narg_blanks',
1781 define.sps:22.1-22.12: error: DEBUG EXPAND: Macro function !BLANKS takes one
1786 define.sps:6: In the expansion of `!narg_concat',
1787 define.sps:23.1-23.12: error: DEBUG EXPAND: Macro function !CONCAT needs at
1792 define.sps:7: In the expansion of `!narg_eval',
1793 define.sps:24.1-24.10: error: DEBUG EXPAND: Macro function !EVAL takes one
1798 define.sps:8: In the expansion of `!narg_head',
1799 define.sps:25.1-25.10: error: DEBUG EXPAND: Macro function !HEAD takes one
1804 define.sps:9: In the expansion of `!narg_index',
1805 define.sps:26.1-26.11: error: DEBUG EXPAND: Macro function !INDEX takes two
1810 define.sps:10: In the expansion of `!narg_length',
1811 define.sps:27.1-27.12: error: DEBUG EXPAND: Macro function !LENGTH takes one
1818 define.sps:12: In the expansion of `!narg_quote',
1819 define.sps:29.1-29.11: error: DEBUG EXPAND: Macro function !QUOTE takes one
1824 define.sps:13: In the expansion of `!narg_substr',
1825 define.sps:30.1-30.12: error: DEBUG EXPAND: Macro function !SUBSTR takes two or
1826 three arguments (not 0).
1830 define.sps:14: In the expansion of `!narg_tail',
1831 define.sps:31.1-31.10: error: DEBUG EXPAND: Macro function !TAIL takes one
1836 define.sps:15: In the expansion of `!narg_unquote',
1837 define.sps:32.1-32.13: error: DEBUG EXPAND: Macro function !UNQUOTE takes one
1842 define.sps:16: In the expansion of `!narg_upcase',
1843 define.sps:33.1-33.12: error: DEBUG EXPAND: Macro function !UPCASE takes one
1850 AT_SETUP([specific macro function syntax errors])
1851 AT_DATA([define.sps], [dnl
1852 DEFINE !a() !BLANKS(x). !ENDDEFINE.
1853 DEFINE !b() !SUBSTR(x, y). !ENDDEFINE.
1854 DEFINE !c() !SUBSTR(x, 1, z). !ENDDEFINE.
1860 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1861 define.sps:1: In the expansion of `!a',
1862 define.sps:5.1-5.2: error: DEBUG EXPAND: Argument to !BLANKS must be non-
1863 negative integer (not "x").
1867 define.sps:2: In the expansion of `!b',
1868 define.sps:6.1-6.2: error: DEBUG EXPAND: Second argument of !SUBSTR must be
1869 positive integer (not "y").
1873 define.sps:3: In the expansion of `!c',
1874 define.sps:7.1-7.2: error: DEBUG EXPAND: Third argument of !SUBSTR must be non-
1875 negative integer (not "z").
1881 AT_SETUP([macro expression errors])
1882 AT_DATA([define.sps], [dnl
1883 DEFINE !a() !LET !x = (1. !ENDDEFINE dnl )
1885 DEFINE !b() !DO !x = x. !ENDDEFINE.
1886 DEFINE !c() !LET !x = (). !ENDDEFINE.
1892 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1893 define.sps:1-2: At `.' in the expansion of `!a',
1894 define.sps:5.1-5.2: error: DEBUG EXPAND: Expecting ')' in macro expression.
1898 At `x' in the expansion of `!DO',
1899 define.sps:2: inside the expansion of `!b',
1900 define.sps:6.1-6.2: error: DEBUG EXPAND: Macro expression must evaluate to a
1905 define.sps:3: At `)' in the expansion of `!c',
1906 define.sps:7.1-7.2: error: DEBUG EXPAND: Expecting literal or function
1907 invocation in macro expression.
1913 AT_SETUP([macro !IF errors])
1915 AT_DATA([define.sps], [dnl
1916 DEFINE !a() !IF 1 !ENDDEFINE.
1917 DEFINE !b() !IF 1 !THEN !ENDDEFINE.
1918 DEFINE !c() !IF 1 !THEN !ELSE !ENDDEFINE.
1924 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1925 define.sps:1: In the expansion of `!a',
1926 define.sps:5.1-5.2: error: DEBUG EXPAND: !THEN expected in macro !IF construct.
1930 define.sps:2: In the expansion of `!b',
1931 define.sps:6.1-6.2: error: DEBUG EXPAND: !ELSE or !IFEND expected in macro !IF
1936 define.sps:3: In the expansion of `!c',
1937 define.sps:7.1-7.2: error: DEBUG EXPAND: !IFEND expected in macro !IF
1944 AT_SETUP([macro !LET errors])
1946 AT_DATA([define.sps], [dnl
1947 DEFINE !a() !LET !ENDDEFINE.
1948 DEFINE !b() !LET 0 !ENDDEFINE.
1949 DEFINE !c() !LET !x !ENDDEFINE.
1950 DEFINE !d() !LET !x y !ENDDEFINE.
1957 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1958 define.sps:1: In the expansion of `!a',
1959 define.sps:6.1-6.2: error: DEBUG EXPAND: Expected macro variable name following
1964 define.sps:2: At `0' in the expansion of `!b',
1965 define.sps:7.1-7.2: error: DEBUG EXPAND: Expected macro variable name following
1970 define.sps:3: In the expansion of `!c',
1971 define.sps:8.1-8.2: error: DEBUG EXPAND: Expected `=' following !LET.
1975 define.sps:4: At `y' in the expansion of `!d',
1976 define.sps:9.1-9.2: error: DEBUG EXPAND: Expected `=' following !LET.
1982 AT_SETUP([macro !DO errors])
1984 AT_DATA([define.sps], [dnl
1985 DEFINE !a() !DO !ENDDEFINE.
1986 DEFINE !b() !DO 0 !ENDDEFINE.
1987 DEFINE !c() !DO !x !ENDDEFINE.
1988 DEFINE !d() !DO !x !in (x) !ENDDEFINE.
1989 DEFINE !e() !DO !x = x. !ENDDEFINE.
1990 DEFINE !f() !DO !x = 5 x !ENDDEFINE.
1991 DEFINE !g() !DO !x = 5 !TO 6 !BY 0 !ENDDEFINE.
1992 DEFINE !h() !DO !x !ENDDEFINE.
1993 DEFINE !i() !DO !x 0 !ENDDEFINE.
1994 DEFINE !j() !BREAK !ENDDEFINE.
2007 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
2008 define.sps:1: In the expansion of `!a',
2009 define.sps:12.1-12.2: error: DEBUG EXPAND: Expected macro variable name
2014 define.sps:2: At `0' in the expansion of `!b',
2015 define.sps:13.1-13.2: error: DEBUG EXPAND: Expected macro variable name
2020 define.sps:3: In the expansion of `!c',
2021 define.sps:14.1-14.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2025 In the expansion of `!DO',
2026 define.sps:4: inside the expansion of `!d',
2027 define.sps:15.1-15.2: error: DEBUG EXPAND: Missing !DOEND.
2031 At `x' in the expansion of `!DO',
2032 define.sps:5: inside the expansion of `!e',
2033 define.sps:16.1-16.2: error: DEBUG EXPAND: Macro expression must evaluate to a
2038 At `x' in the expansion of `!DO',
2039 define.sps:6: inside the expansion of `!f',
2040 define.sps:17.1-17.2: error: DEBUG EXPAND: Expected !TO in numerical !DO loop.
2044 In the expansion of `!DO',
2045 define.sps:7: inside the expansion of `!g',
2046 define.sps:18.1-18.2: error: DEBUG EXPAND: !BY value cannot be zero.
2048 !DO !x = 5 !TO 6 !BY 0
2050 define.sps:8: In the expansion of `!h',
2051 define.sps:19.1-19.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2055 define.sps:9: At `0' in the expansion of `!i',
2056 define.sps:20.1-20.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2060 define.sps:10: At `!BREAK' in the expansion of `!j',
2061 define.sps:21.1-21.2: error: DEBUG EXPAND: !BREAK outside !DO.
2066 AT_SETUP([macros in comments])
2067 AT_KEYWORDS([macro])
2068 AT_DATA([define.sps], [dnl
2069 DEFINE !macro() x y z !ENDDEFINE.
2075 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
2080 AT_SETUP([DEFINE syntax errors])
2081 AT_KEYWORDS([macro])
2082 AT_DATA([define.sps], [dnl
2083 DEFINE !macro(!POSITIONAL !CHAREND('x y')) !ENDDEFINE.
2084 DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2085 DEFINE !macro(!a=!TOKENS(1)) !ENDDEFINE.
2086 DEFINE !macro(do=!TOKENS(1)) !ENDDEFINE.
2087 DEFINE 0() !ENDDEFINE.
2088 DEFINE x y () !ENDDEFINE.
2089 DEFINE !macro(1) !ENDDEFINE.
2090 DEFINE !macro(x 2) !ENDDEFINE.
2091 DEFINE !macro(x=!DEFAULT 3) !ENDDEFINE.
2092 DEFINE !macro(x=!TOKENS 4) !ENDDEFINE.
2093 DEFINE !macro(x=!TOKENS(x)) !ENDDEFINE.
2094 DEFINE !macro(x=!TOKENS(1 5)) !ENDDEFINE.
2095 DEFINE !macro(x=!ENCLOSE 6) !ENDDEFINE.
2096 DEFINE !macro(x=!ENCLOSE('x' y)) !ENDDEFINE.
2097 DEFINE !macro(x=!ENCLOSE('x',y)) !ENDDEFINE.
2098 DEFINE !macro(x=!ENCLOSE('x','y' z)) !ENDDEFINE.
2099 DEFINE !macro(x=!CHAREND 7) !ENDDEFINE.
2100 DEFINE !macro(x=!CHAREND(8)) !ENDDEFINE.
2101 DEFINE !macro(x=!CHAREND('x' 9)) !ENDDEFINE.
2102 DEFINE !macro(x=!WTF) !ENDDEFINE.
2103 DEFINE !macro(x=!TOKENS(1) x) !ENDDEFINE.
2104 DEFINE !macro(x=!DEFAULT() !DEFAULT()) !ENDDEFINE.
2105 DEFINE !macro(x=!TOKENS(1) !CMDEND) !ENDDEFINE.
2108 AT_CHECK([pspp define.sps], [1], [dnl
2109 define.sps:1.36-1.40: error: DEFINE: Syntax error at `'x y'': String must
2110 contain exactly one token.
2112 define.sps:2.40-2.46: error: DEFINE: Syntax error at `!TOKENS': Positional
2113 parameters must precede keyword parameters.
2115 define.sps:3.15-3.16: error: DEFINE: Syntax error at `!a': Keyword macro
2116 parameter must be named in definition without "!" prefix.
2118 define.sps:4.15-4.16: error: DEFINE: Syntax error at `do': Cannot use macro
2119 keyword "do" as an argument name.
2121 define.sps:5.8: error: DEFINE: Syntax error at `0': expecting identifier.
2123 define.sps:6.10: error: DEFINE: Syntax error at `y': expecting `@{:@'.
2125 define.sps:7.15: error: DEFINE: Syntax error at `1': expecting identifier.
2127 define.sps:8.17: error: DEFINE: Syntax error at `2': expecting !TOKENS, !
2128 CHAREND, !ENCLOSE, or !CMDEND.
2130 define.sps:9.26: error: DEFINE: Syntax error at `3': expecting `@{:@'.
2132 define.sps:10.25: error: DEFINE: Syntax error at `4': expecting `('.
2134 define.sps:11.25: error: DEFINE: Syntax error at `x': Expected positive integer
2137 define.sps:12.27: error: DEFINE: Syntax error at `5': expecting `)'.
2139 define.sps:13.26: error: DEFINE: Syntax error at `6': expecting `('.
2141 define.sps:14.30: error: DEFINE: Syntax error at `y': expecting `,'.
2143 define.sps:15.30: error: DEFINE: Syntax error at `y': expecting string.
2145 define.sps:16.34: error: DEFINE: Syntax error at `z': expecting `)'.
2147 define.sps:17.26: error: DEFINE: Syntax error at `7': expecting `('.
2149 define.sps:18.26: error: DEFINE: Syntax error at `8': expecting string.
2151 define.sps:19.30: error: DEFINE: Syntax error at `9': expecting `)'.
2153 define.sps:20.17-20.20: error: DEFINE: Syntax error at `!WTF': expecting !
2154 TOKENS, !CHAREND, !ENCLOSE, or !CMDEND.
2156 define.sps:21.28: error: DEFINE: Syntax error at `x': expecting `/'.
2158 define.sps:22.36: error: DEFINE: Syntax error at `(': !DEFAULT is allowed only
2161 define.sps:23.35: error: DEFINE: Syntax error at `)': Only one of !TOKENS, !
2162 CHAREND, !ENCLOSE, or !CMDEND is allowed.
2164 define.sps:25.1: error: DEFINE: Syntax error at end of command: Expecting macro
2169 AT_SETUP([macro expansion with token merging])
2170 AT_DATA([define.sps], [dnl
2171 DEFINE !foo() "foo" !ENDDEFINE.
2172 DEFINE !bar() "bar" !ENDDEFINE.
2173 DEFINE !plus() + !ENDDEFINE.
2174 DEFINE !minus() - !ENDDEFINE.
2175 DEFINE !one() 1 !ENDDEFINE.
2182 ECHO !foo !plus !bar.
2183 ECHO "two" "strings".
2185 N OF CASES !minus 1.
2187 N OF CASES !minus !one.
2189 AT_CHECK([pspp define.sps], [1], [dnl
2206 define.sps:13.12-13.20: error: ECHO: Syntax error at `"strings"': expecting end
2209 define.sps:14.12-14.17: error: N OF CASES: Syntax error at `-/**/1': Expected
2210 positive integer for N OF CASES.
2212 define.sps:15.12-15.19: error: N OF CASES: Syntax error at `!minus 1': Expected
2213 positive integer for N OF CASES.
2215 define.sps:16.12-16.17: error: N OF CASES: Syntax error at `- !one': Expected
2216 positive integer for N OF CASES.
2218 define.sps:17.12-17.22: error: N OF CASES: Syntax error at `!minus !one':
2219 Expected positive integer for N OF CASES.
2223 AT_SETUP([one macro calls another])
2224 AT_DATA([define.sps], [dnl
2225 DEFINE !a(!pos !enclose('(',')')) [[!1]] !ENDDEFINE.
2226 DEFINE !b(!pos !enclose('{','}')) !a(x !1 z) !ENDDEFINE.
2227 DEFINE !c(!pos !enclose('{','}')) !let !tmp=!quote(!concat('<',!1,'>')) !a(!tmp) !ENDDEFINE.
2232 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl