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([macro expansion - one !TOKENS(1) positional argument])
46 AT_DATA([define.sps], [dnl
47 DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE.
53 AT_CAPTURE_FILE([define.sps])
54 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
61 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 note: unexpanded token "7"
176 "Three !TOKENS(1) arguments."
180 p(1, -2, -3) (1 -2 -3)
184 AT_SETUP([macro call missing positional !TOKENS arguments])
185 AT_KEYWORDS([TOKENS])
186 AT_DATA([define.sps], [dnl
187 DEFINE !p(!positional !tokens(1) !default(x)
188 /!positional !tokens(1) !default(y)
189 /!positional !tokens(1) !default(z))
198 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
209 AT_SETUP([macro call incomplete positional !TOKENS arguments])
210 AT_KEYWORDS([TOKENS])
211 AT_DATA([define.sps], [dnl
212 DEFINE !p(!positional !tokens(2) !default(x)
213 /!positional !tokens(2) !default(y)
214 /!positional !tokens(2) !default(z))
218 !p a1 a2 b1 b2 c1 c2.
226 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
227 (a1 a2, b1 b2, c1 c2)
229 define.sps:8.18: error: DEBUG EXPAND: Reached end of command expecting 1 more
230 token in argument !3 to macro !p.
236 define.sps:10.12: error: DEBUG EXPAND: Reached end of command expecting 1 more
237 token in argument !2 to macro !p.
243 define.sps:12.6: error: DEBUG EXPAND: Reached end of command expecting 1 more
244 token in argument !1 to macro !p.
252 AT_SETUP([macro call empty positional !CHAREND arguments])
253 AT_KEYWORDS([CHAREND])
254 AT_DATA([define.sps], [dnl
255 DEFINE !p(!positional !charend(',') !default(x)
256 /!positional !charend(';') !default(y)
257 /!positional !charend(':') !default(z))
270 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
289 AT_SETUP([macro call missing positional !CHAREND arguments])
290 AT_DATA([define.sps], [dnl
291 DEFINE !p(!positional !charend(',') !default(x)
292 /!positional !charend(';') !default(y)
293 /!positional !charend(':') !default(z))
308 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
327 AT_SETUP([macro call incomplete positional !CHAREND arguments])
328 AT_KEYWORDS([CHAREND])
329 AT_DATA([define.sps], [dnl
330 DEFINE !p(!positional !charend(',') !default(x)
331 /!positional !charend(';') !default(y)
332 /!positional !charend(':') !default(z))
344 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
347 define.sps:8.9: error: DEBUG EXPAND: Reached end of command expecting ":" in
348 argument !3 to macro !p.
354 define.sps:10.7: error: DEBUG EXPAND: Reached end of command expecting ";" in
355 argument !2 to macro !p.
361 define.sps:12.5: error: DEBUG EXPAND: Reached end of command expecting "," in
362 argument !1 to macro !p.
370 AT_SETUP([macro call missing positional !ENCLOSE arguments])
371 AT_KEYWORDS([ENCLOSE])
372 AT_DATA([define.sps], [dnl
373 DEFINE !p(!positional !enclose('(',')') !default(x)
374 /!positional !enclose('<','>') !default(y)
375 /!positional !enclose('{','}') !default(z))
384 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
395 AT_SETUP([macro call incomplete positional !ENCLOSE arguments])
396 AT_KEYWORDS([ENCLOSE])
397 AT_DATA([define.sps], [dnl
398 DEFINE !p(!positional !enclose('(',')') !default(x)
399 /!positional !enclose('<','>') !default(y)
400 /!positional !enclose('{','}') !default(z))
415 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
418 define.sps:8.12: error: DEBUG EXPAND: Reached end of command expecting "}" in
419 argument !3 to macro !p.
423 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "}" in
424 argument !3 to macro !p.
430 define.sps:11.9: error: DEBUG EXPAND: Reached end of command expecting ">" in
431 argument !2 to macro !p.
435 define.sps:12.8: error: DEBUG EXPAND: Reached end of command expecting ">" in
436 argument !2 to macro !p.
442 define.sps:14.6: error: DEBUG EXPAND: Reached end of command expecting ")" in
443 argument !1 to macro !p.
447 define.sps:15.5: error: DEBUG EXPAND: Reached end of command expecting ")" in
448 argument !1 to macro !p.
456 AT_SETUP([keyword macro argument name with ! prefix])
457 AT_DATA([define.sps], [dnl
458 DEFINE !macro(!x !TOKENS(1).
460 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
461 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `!x': Keyword macro parameter must be named in definition without ""!"" prefix."
465 AT_SETUP([reserved macro keyword argument name])
466 AT_DATA([define.sps], [dnl
467 DEFINE !macro(if=!TOKENS(1).
469 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
470 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `if': Cannot use macro keyword ""if"" as an argument name."
474 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument])
475 AT_KEYWORDS([TOKENS])
476 AT_DATA([define.sps], [dnl
477 DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.
483 AT_CAPTURE_FILE([define.sps])
484 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
489 note: unexpanded token "y"
495 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative])
496 AT_KEYWORDS([TOKENS])
497 AT_DATA([define.sps], [dnl
498 DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE.
503 AT_CAPTURE_FILE([define.sps])
504 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
505 define.sps:3.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
506 argument !arg1 to macro !k.
508 note: unexpanded token "!k"
510 note: unexpanded token "arg1"
512 define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more
513 token in argument !arg1 to macro !k.
519 AT_SETUP([macro expansion - !CHAREND keyword arguments])
520 AT_KEYWORDS([CHAREND])
521 AT_DATA([define.sps], [dnl
522 DEFINE !k(arg1 = !CHAREND('/')
523 /arg2 = !CHAREND('/'))
532 AT_CAPTURE_FILE([define.sps])
533 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
544 AT_SETUP([macro expansion - !CHAREND keyword arguments - negative])
545 AT_KEYWORDS([CHAREND])
546 AT_DATA([define.sps], [dnl
547 DEFINE !k(arg1 = !CHAREND('/')
548 /arg2 = !CHAREND('/'))
557 AT_CAPTURE_FILE([define.sps])
558 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
559 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
560 argument !arg1 to macro !k.
562 note: unexpanded token "!k"
564 note: unexpanded token "arg1"
566 define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in
567 argument !arg1 to macro !k.
571 define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in
572 argument !arg1 to macro !k.
576 define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in
577 argument !arg2 to macro !k.
583 AT_SETUP([macro expansion - !ENCLOSE keyword arguments])
584 AT_KEYWORDS([ENCLOSE])
585 AT_DATA([define.sps], [dnl
586 DEFINE !k(arg1 = !ENCLOSE('(',')')
587 /arg2 = !ENCLOSE('{','}'))
591 !k arg1=(x) arg2={y}.
596 AT_CAPTURE_FILE([define.sps])
597 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
608 AT_SETUP([macro expansion - !ENCLOSE keyword arguments - negative])
609 AT_KEYWORDS([ENCLOSE])
610 AT_DATA([define.sps], [dnl
611 DEFINE !k(arg1 = !ENCLOSE('(',')')
612 /arg2 = !ENCLOSE('{','}'))
625 AT_CAPTURE_FILE([define.sps])
626 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
627 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
628 argument !arg1 to macro !k.
630 note: unexpanded token "!k"
632 note: unexpanded token "arg1"
634 define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading
635 argument !arg1 to macro !k.
637 note: unexpanded token "!k"
639 note: unexpanded token "arg1"
641 note: unexpanded token "="
643 define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading
644 argument !arg1 to macro !k.
646 note: unexpanded token "!k"
648 note: unexpanded token "arg1"
650 note: unexpanded token "="
652 note: unexpanded token "x"
654 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "@:}@" in
655 argument !arg1 to macro !k.
659 define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading
660 argument !arg2 to macro !k.
662 note: unexpanded token "!k"
664 note: unexpanded token "arg1"
666 note: unexpanded token "="
668 note: unexpanded token "@{:@"
670 note: unexpanded token "x"
672 note: unexpanded token "@:}@"
674 note: unexpanded token "arg2"
676 define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading
677 argument !arg2 to macro !k.
679 note: unexpanded token "!k"
681 note: unexpanded token "arg1"
683 note: unexpanded token "="
685 note: unexpanded token "@{:@"
687 note: unexpanded token "x"
689 note: unexpanded token "@:}@"
691 note: unexpanded token "arg2"
693 note: unexpanded token "="
695 define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading
696 argument !arg2 to macro !k.
698 note: unexpanded token "!k"
700 note: unexpanded token "arg1"
702 note: unexpanded token "="
704 note: unexpanded token "@{:@"
706 note: unexpanded token "x"
708 note: unexpanded token "@:}@"
710 note: unexpanded token "arg2"
712 note: unexpanded token "="
714 note: unexpanded token "y"
716 define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading
717 argument !arg2 to macro !k.
719 note: unexpanded token "!k"
721 note: unexpanded token "arg1"
723 note: unexpanded token "="
725 note: unexpanded token "@{:@"
727 note: unexpanded token "x"
729 note: unexpanded token "@:}@"
731 note: unexpanded token "arg2"
733 note: unexpanded token "="
735 note: unexpanded token "@{:@"
737 note: unexpanded token "y"
741 dnl Keep this test in sync with the examples for !BLANKS in the manual.
742 AT_SETUP([macro expansion - !BLANKS])
743 AT_KEYWORDS([BLANKS])
744 AT_DATA([define.sps], [dnl
758 AT_CAPTURE_FILE([define.sps])
759 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
771 dnl Keep this test in sync with the examples for !CONCAT in the manual.
772 AT_SETUP([macro expansion - !CONCAT])
773 AT_KEYWORDS([CONCAT])
774 AT_DATA([define.sps], [dnl
788 AT_CAPTURE_FILE([define.sps])
789 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
801 dnl Keep this test in sync with the examples for !EVAL in the manual.
802 AT_SETUP([macro expansion - !EVAL])
804 AT_DATA([define.sps], [dnl
805 DEFINE !vars() a b c !ENDDEFINE.
811 !QUOTE(!EVAL(!vars)).
814 DEFINE !e2(!positional !enclose('(',')'))
824 AT_CAPTURE_FILE([define.sps])
825 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
838 dnl Keep this test in sync with the examples for !HEAD in the manual.
839 AT_SETUP([macro expansion - !HEAD])
841 AT_DATA([define.sps], [dnl
851 AT_CAPTURE_FILE([define.sps])
852 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
860 dnl Keep this test in sync with the examples for !TAIL in the manual.
861 AT_SETUP([macro expansion - !TAIL])
863 AT_DATA([define.sps], [dnl
873 AT_CAPTURE_FILE([define.sps])
874 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
882 dnl Keep this test in sync with the examples for !INDEX in the manual.
883 AT_SETUP([macro expansion - !INDEX])
885 AT_DATA([define.sps], [dnl
889 !INDEX(banana, apple).
890 !INDEX("banana", nan).
891 !INDEX("banana", "nan").
892 !INDEX(!UNQUOTE("banana"), !UNQUOTE("nan")).
897 AT_CAPTURE_FILE([define.sps])
898 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
908 dnl Keep this test in sync with the examples for !LENGTH in the manual.
909 AT_SETUP([macro expansion - !LENGTH])
910 AT_KEYWORDS([LENGTH])
911 AT_DATA([define.sps], [dnl
920 !LENGTH(!UNQUOTE("xyzzy")).
921 !LENGTH(!UNQUOTE("xy""zzy")).
924 DEFINE !la(!positional !enclose('(',')'))
932 AT_CAPTURE_FILE([define.sps])
933 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
951 dnl Keep this test in sync with the examples for !SUBSTR in the manual.
952 AT_SETUP([macro expansion - !SUBSTR])
953 AT_KEYWORDS([SUBSTR])
954 AT_DATA([define.sps], [dnl
957 !SUBSTR(banana, 3, 3).
958 !SUBSTR("banana", 1, 3).
959 !SUBSTR(!UNQUOTE("banana"), 3).
960 !SUBSTR("banana", 3, 3).
961 !SUBSTR(banana, 3, 0).
962 !SUBSTR(banana, 3, 10).
963 !SUBSTR(banana, 10, 3).
968 AT_CAPTURE_FILE([define.sps])
969 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
970 define.sps:1-10: At `"ba' in the expansion of `!s',dnl "
972 define.sps:12.1-12.2: error: DEBUG EXPAND: Unterminated string constant.
985 dnl Keep this test in sync with the examples for !UPCASE in the manual.
986 AT_SETUP([macro expansion - !UPCASE])
987 AT_KEYWORDS([UPCASE])
988 AT_DATA([define.sps], [dnl
998 AT_CAPTURE_FILE([define.sps])
999 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1007 dnl !* is implemented separately inside and outside function arguments
1008 dnl so this test makes sure to include both.
1009 AT_SETUP([macro expansion - !*])
1010 AT_DATA([define.sps], [dnl
1011 DEFINE !m(!POSITIONAL !TOKENS(1)
1012 /!POSITIONAL !TOKENS(1))
1023 AT_CAPTURE_FILE([define.sps])
1024 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1025 123 b / 5 / 3 b / '123 b'.
1027 2 3 / 3 / 3 / '2 3'.
1029 '' 'b' / 6 / 'b' / ''''' ''b'''.
1033 AT_SETUP([macro maximum nesting level (MNEST)])
1034 AT_KEYWORDS([MNEST])
1035 AT_DATA([define.sps], [dnl
1041 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1042 "define.sps:1-3: In the expansion of `!macro',
1043 define.sps:1-3: inside the expansion of `!macro',
1044 define.sps:1-3: inside the expansion of `!macro',
1045 define.sps:1-3: inside the expansion of `!macro',
1046 define.sps:1-3: inside the expansion of `!macro',
1047 define.sps:1-3: inside the expansion of `!macro',
1048 define.sps:1-3: inside the expansion of `!macro',
1049 define.sps:1-3: inside the expansion of `!macro',
1050 define.sps:1-3: inside the expansion of `!macro',
1051 define.sps:1-3: inside the expansion of `!macro',
1052 define.sps:1-3: inside 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:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.)"
1095 define.sps:4.1-4.6: error: Syntax error at `!macro' (in expansion of `!macro'): expecting command name.
1099 AT_SETUP([macro !IF condition])
1102 '!eq !ne !lt !gt !le !ge' \
1106 AS_BOX([$operators])
1107 cat > define.sps <<EOF
1108 DEFINE !test(!positional !tokens(1))
1109 !if (!1 $1 1) !then true !else false !ifend
1110 !if (!1 $2 1) !then true !else false !ifend
1111 !if (!1 $3 1) !then true !else false !ifend
1112 !if (!1 $4 1) !then true !else false !ifend
1113 !if (!1 $5 1) !then true !else false !ifend
1114 !if (!1 $6 1) !then true !else false !ifend.
1123 AT_CAPTURE_FILE([define.sps])
1124 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1125 false true true false true false.
1127 true false false false true true.
1129 false true false true false true.
1131 true false false false true true.
1133 false true false true false true.
1138 AT_SETUP([macro !IF condition -- case sensitivity])
1141 '!eq !ne !lt !gt !le !ge' \
1145 AS_BOX([$operators])
1146 cat > define.sps <<EOF
1147 DEFINE !test(!positional !tokens(1))
1148 !if (!1 $1 a) !then true !else false !ifend
1149 !if (!1 $1 A) !then true !else false !ifend
1150 !if (!1 $2 a) !then true !else false !ifend
1151 !if (!1 $2 A) !then true !else false !ifend
1152 !if (!1 $3 a) !then true !else false !ifend
1153 !if (!1 $3 A) !then true !else false !ifend
1154 !if (!1 $4 a) !then true !else false !ifend
1155 !if (!1 $4 A) !then true !else false !ifend
1156 !if (!1 $5 a) !then true !else false !ifend
1157 !if (!1 $5 A) !then true !else false !ifend
1158 !if (!1 $6 a) !then true !else false !ifend
1159 !if (!1 $6 A) !then true !else false !ifend
1160 !if (!1 $1 !null) !then true !else false !ifend
1161 !if (!1 $2 !null) !then true !else false !ifend.
1169 AT_CAPTURE_FILE([define.sps])
1170 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1171 true false false true false false false true true false true true false true.
1173 false true true false true false false false true true false true false true.
1175 false false true true false false true true false false true true false true.
1177 false false true true true false false true true false false true false true.
1182 AT_SETUP([macro !IF condition -- logical operators])
1189 AS_BOX([$operators])
1190 cat > define.sps <<EOF
1191 DEFINE !test_binary(!positional !tokens(1)/!positional !tokens(1))
1192 !if !1 $1 !2 !then true !else false !ifend
1193 !if !1 $2 !2 !then true !else false !ifend.
1196 DEFINE !test_unary(!positional !tokens(1))
1197 !if $3 !1 !then true !else false !ifend.
1201 ((not A) and B) or C
1204 DEFINE !test_prec(!pos !tokens(1)/!pos !tokens(1)/!pos !tokens(1))
1205 !if $3 !1 $1 !2 $2 !3 !then true !else false !ifend
1206 !if $3 (!1 $1 !2) $2 !3 !then true !else false !ifend
1207 !if $3 !1 $1 (!2 $2 !3) !then true !else false !ifend
1217 !test_prec 0 0 0 !test_prec 0 0 1 !test_prec 0 1 0 !test_prec 0 1 1.
1218 !test_prec 1 0 0 !test_prec 1 0 1 !test_prec 1 1 0 !test_prec 1 1 1.
1220 AT_CAPTURE_FILE([define.sps])
1221 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1247 AT_SETUP([macro !LET])
1249 AT_DATA([define.sps], [dnl
1250 DEFINE !macro(!POS !CMDEND)
1251 !LET !v1 = !CONCAT('x',!1,'y')
1252 !LET !v2 = !QUOTE(!v1)
1253 !LET !v3 = (!LENGTH(!1) = 1)
1254 !LET !v4 = (!SUBSTR(!1, 3) = !NULL)
1265 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1283 AT_SETUP([macro indexed !DO])
1284 AT_KEYWORDS([index do])
1285 AT_DATA([define.sps], [dnl
1286 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1288 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1289 !DO !var = !1 !TO !2 !var !DOEND.
1292 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1293 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1297 !title "increasing".
1304 !title "decreasing".
1311 !title "non-integer".
1314 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1345 AT_SETUP([macro !DO invalid variable names])
1346 AT_KEYWORDS([index do])
1347 AT_DATA([define.sps], [dnl
1348 DEFINE !for(x=!TOKENS(1) / y=!TOKENS(1))
1349 !DO !x = !x !TO !y !var !DOEND.
1352 DEFINE !for2(x=!TOKENS(1) / y=!TOKENS(1))
1353 !DO !noexpand = !x !TO !y !var !DOEND.
1360 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1361 define.sps:1-3: At `!x' in the expansion of `!for',
1362 define.sps:10.1-10.12: error: DEBUG EXPAND: Cannot use argument name or macro
1363 keyword as !DO variable.
1365 !DO 1 = 1 !TO 5 !var !DOEND.
1367 define.sps:5-7: At `!noexpand' in the expansion of `!for2',
1368 define.sps:11.1-11.13: error: DEBUG EXPAND: Cannot use argument name or macro
1369 keyword as !DO variable.
1371 !DO !noexpand = 1 !TO 5 !var !DOEND.
1375 AT_SETUP([macro indexed !DO reaches MITERATE])
1376 AT_KEYWORDS([index do])
1377 AT_DATA([define.sps], [dnl
1378 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1380 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1381 !DO !var = !1 !TO !2 !var !DOEND.
1384 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1385 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1390 !title "increasing".
1397 !title "decreasing".
1404 !title "non-integer".
1407 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1410 In the expansion of `!DO',
1411 define.sps:3-5: inside the expansion of `!for',
1412 define.sps:14.1-14.8: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1413 number of iterations 3. (Use SET MITERATE to change the limit.)
1417 In the expansion of `!DO',
1418 define.sps:7-9: inside the expansion of `!forby',
1419 define.sps:15.1-15.12: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1420 number of iterations 3. (Use SET MITERATE to change the limit.)
1436 In the expansion of `!DO',
1437 define.sps:7-9: inside the expansion of `!forby',
1438 define.sps:23.1-23.13: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1439 number of iterations 3. (Use SET MITERATE to change the limit.)
1453 AT_SETUP([!BREAK with macro indexed !DO])
1454 AT_KEYWORDS([index do break])
1455 AT_DATA([define.sps], [dnl
1456 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1458 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1459 !DO !var = !1 !TO !2
1475 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1480 AT_SETUP([macro list !DO])
1481 AT_KEYWORDS([index do])
1482 AT_DATA([define.sps], [dnl
1483 DEFINE !for(!POS !CMDEND)
1484 (!DO !i !IN (!1) (!i) !DOEND).
1489 !for 'foo bar baz quux'.
1492 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1495 ( (foo) (bar) (baz) (quux) ).
1501 AT_SETUP([macro list !DO reaches MITERATE])
1502 AT_KEYWORDS([index do])
1503 AT_DATA([define.sps], [dnl
1504 DEFINE !for(!POS !CMDEND)
1505 (!DO !i !IN (!1) (!i) !DOEND).
1511 !for 'foo bar baz quux'.
1514 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1515 In the expansion of `!DO',
1516 define.sps:1-3: inside the expansion of `!for',
1517 define.sps:7.1-7.10: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1518 number of iterations 2. (Use SET MITERATE to change the limit.)
1522 In the expansion of `!DO',
1523 define.sps:1-3: inside the expansion of `!for',
1524 define.sps:8.1-8.23: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1525 number of iterations 2. (Use SET MITERATE to change the limit.)
1533 AT_SETUP([!BREAK with macro list !DO])
1534 AT_KEYWORDS([index break do])
1535 AT_DATA([define.sps], [dnl
1536 DEFINE !for(!POS !TOKENS(1) / !POS !CMDEND)
1552 !for baz 'foo bar baz quux'.
1555 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1558 ( (foo), (bar), (baz)x).
1564 AT_SETUP([macro !LET])
1565 AT_DATA([define.sps], [dnl
1566 DEFINE !macro(!pos !enclose('(',')'))
1577 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl
1584 AT_SETUP([macro !LET invalid variable names])
1585 AT_DATA([define.sps], [dnl
1586 DEFINE !macro(x=!tokens(1))
1598 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [1], [dnl
1599 "define.sps:1-3: At `!x' in the expansion of `!macro',
1600 define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable."
1604 "define.sps:5-7: At `!do' in the expansion of `!macro2',
1605 define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable."
1607 "define.sps:5-7: At `=' in the expansion of `!macro2',
1608 define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO."
1614 AT_SETUP([BEGIN DATA inside a macro])
1615 AT_DATA([define.sps], [dnl
1617 DATA LIST NOTABLE /x 1.
1628 AT_CHECK([pspp define.sps -O format=csv], [0], [dnl
1637 AT_SETUP([TITLE and SUBTITLE with macros])
1638 AT_KEYWORDS([macro])
1639 for command in TITLE SUBTITLE; do
1640 cat >title.sps <<EOF
1641 DEFINE !paste(!POS !TOKENS(1) / !POS !TOKENS(1))
1644 $command prefix !paste foo bar suffix.
1648 title.sps:5: note: SHOW: $command is prefix foobar suffix.
1650 AT_CHECK([pspp -O format=csv title.sps], [0], [expout])
1654 AT_SETUP([error message within macro expansion])
1655 AT_DATA([define.sps], [dnl
1656 DEFINE !vars(!POS !TOKENS(1)) a b C !ENDDEFINE.
1657 DATA LIST NOTABLE /a b 1-2.
1658 COMPUTE x = !vars x.
1660 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1661 define.sps:3.13-3.19: error: COMPUTE: Syntax error at `b' (in expansion of `!vars x'): expecting end of command.
1665 dnl A macro with keyword arguments needs a token of lookahead
1666 dnl to find out whether another keyword is present. Test that
1667 dnl this special case works OK.
1668 AT_SETUP([macro calls in each others' lookahead])
1669 AT_DATA([define.sps], [dnl
1670 DEFINE !k(x=!DEFAULT(0) !TOKENS(1)/y=!DEFAULT(0) !TOKENS(1))
1680 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1692 AT_SETUP([bad token in macro body])
1693 AT_DATA([define.sps], [dnl
1698 AT_CHECK([pspp define.sps], [1], [dnl
1699 define.sps:3: error: DEFINE: String of hex digits has 3 characters, which is
1700 not a multiple of 2.
1704 AT_SETUP([generic macro function syntax errors])
1705 AT_DATA([define.sps], [dnl
1706 DEFINE !a() !SUBSTR !ENDDEFINE.
1707 DEFINE !b() !SUBSTR x !ENDDEFINE.
1708 DEFINE !c() !SUBSTR(1x) !ENDDEFINE.
1709 DEFINE !d() !SUBSTR(1 !ENDDEFINE.
1710 DEFINE !narg_blanks() !BLANKS() !ENDDEFINE.
1711 DEFINE !narg_concat() !CONCAT() !ENDDEFINE.
1712 DEFINE !narg_eval() !EVAL() !ENDDEFINE.
1713 DEFINE !narg_head() !HEAD() !ENDDEFINE.
1714 DEFINE !narg_index() !INDEX() !ENDDEFINE.
1715 DEFINE !narg_length() !LENGTH() !ENDDEFINE.
1716 DEFINE !narg_null() !NULL() !ENDDEFINE.
1717 DEFINE !narg_quote() !QUOTE() !ENDDEFINE.
1718 DEFINE !narg_substr() !SUBSTR() !ENDDEFINE.
1719 DEFINE !narg_tail() !TAIL() !ENDDEFINE.
1720 DEFINE !narg_unquote() !UNQUOTE() !ENDDEFINE.
1721 DEFINE !narg_upcase() !UPCASE() !ENDDEFINE.
1741 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1742 define.sps:1: In the expansion of `!a',
1743 define.sps:18.1-18.2: error: DEBUG EXPAND: `@{:@' expected following !SUBSTR.
1747 define.sps:2: At `x' in the expansion of `!b',
1748 define.sps:19.1-19.2: error: DEBUG EXPAND: `@{:@' expected following !SUBSTR.
1752 define.sps:3: At `x' in the expansion of `!c',
1753 define.sps:20.1-20.2: error: DEBUG EXPAND: `,' or `@:}@' expected in call to macro
1758 define.sps:4: In the expansion of `!d',
1759 define.sps:21.1-21.2: error: DEBUG EXPAND: Missing `@:}@' in call to macro
1764 define.sps:5: In the expansion of `!narg_blanks',
1765 define.sps:22.1-22.12: error: DEBUG EXPAND: Macro function !BLANKS takes one
1770 define.sps:6: In the expansion of `!narg_concat',
1771 define.sps:23.1-23.12: error: DEBUG EXPAND: Macro function !CONCAT needs at
1776 define.sps:7: In the expansion of `!narg_eval',
1777 define.sps:24.1-24.10: error: DEBUG EXPAND: Macro function !EVAL takes one
1782 define.sps:8: In the expansion of `!narg_head',
1783 define.sps:25.1-25.10: error: DEBUG EXPAND: Macro function !HEAD takes one
1788 define.sps:9: In the expansion of `!narg_index',
1789 define.sps:26.1-26.11: error: DEBUG EXPAND: Macro function !INDEX takes two
1794 define.sps:10: In the expansion of `!narg_length',
1795 define.sps:27.1-27.12: error: DEBUG EXPAND: Macro function !LENGTH takes one
1802 define.sps:12: In the expansion of `!narg_quote',
1803 define.sps:29.1-29.11: error: DEBUG EXPAND: Macro function !QUOTE takes one
1808 define.sps:13: In the expansion of `!narg_substr',
1809 define.sps:30.1-30.12: error: DEBUG EXPAND: Macro function !SUBSTR takes two or
1810 three arguments (not 0).
1814 define.sps:14: In the expansion of `!narg_tail',
1815 define.sps:31.1-31.10: error: DEBUG EXPAND: Macro function !TAIL takes one
1820 define.sps:15: In the expansion of `!narg_unquote',
1821 define.sps:32.1-32.13: error: DEBUG EXPAND: Macro function !UNQUOTE takes one
1826 define.sps:16: In the expansion of `!narg_upcase',
1827 define.sps:33.1-33.12: error: DEBUG EXPAND: Macro function !UPCASE takes one
1834 AT_SETUP([specific macro function syntax errors])
1835 AT_DATA([define.sps], [dnl
1836 DEFINE !a() !BLANKS(x). !ENDDEFINE.
1837 DEFINE !b() !SUBSTR(x, y). !ENDDEFINE.
1838 DEFINE !c() !SUBSTR(x, 1, z). !ENDDEFINE.
1844 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1845 define.sps:1: In the expansion of `!a',
1846 define.sps:5.1-5.2: error: DEBUG EXPAND: Argument to !BLANKS must be non-
1847 negative integer (not "x").
1851 define.sps:2: In the expansion of `!b',
1852 define.sps:6.1-6.2: error: DEBUG EXPAND: Second argument of !SUBSTR must be
1853 positive integer (not "y").
1857 define.sps:3: In the expansion of `!c',
1858 define.sps:7.1-7.2: error: DEBUG EXPAND: Third argument of !SUBSTR must be non-
1859 negative integer (not "z").
1865 AT_SETUP([macro expression errors])
1866 AT_DATA([define.sps], [dnl
1867 DEFINE !a() !LET !x = (1. !ENDDEFINE dnl )
1869 DEFINE !b() !DO !x = x. !ENDDEFINE.
1870 DEFINE !c() !LET !x = (). !ENDDEFINE.
1876 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1877 define.sps:1-2: At `.' in the expansion of `!a',
1878 define.sps:5.1-5.2: error: DEBUG EXPAND: Expecting ')' in macro expression.
1882 At `x' in the expansion of `!DO',
1883 define.sps:2: inside the expansion of `!b',
1884 define.sps:6.1-6.2: error: DEBUG EXPAND: Macro expression must evaluate to a
1889 define.sps:3: At `)' in the expansion of `!c',
1890 define.sps:7.1-7.2: error: DEBUG EXPAND: Expecting literal or function
1891 invocation in macro expression.
1897 AT_SETUP([macro !IF errors])
1899 AT_DATA([define.sps], [dnl
1900 DEFINE !a() !IF 1 !ENDDEFINE.
1901 DEFINE !b() !IF 1 !THEN !ENDDEFINE.
1902 DEFINE !c() !IF 1 !THEN !ELSE !ENDDEFINE.
1908 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1909 define.sps:1: In the expansion of `!a',
1910 define.sps:5.1-5.2: error: DEBUG EXPAND: !THEN expected in macro !IF construct.
1914 define.sps:2: In the expansion of `!b',
1915 define.sps:6.1-6.2: error: DEBUG EXPAND: !ELSE or !IFEND expected in macro !IF
1920 define.sps:3: In the expansion of `!c',
1921 define.sps:7.1-7.2: error: DEBUG EXPAND: !IFEND expected in macro !IF
1928 AT_SETUP([macro !LET errors])
1930 AT_DATA([define.sps], [dnl
1931 DEFINE !a() !LET !ENDDEFINE.
1932 DEFINE !b() !LET 0 !ENDDEFINE.
1933 DEFINE !c() !LET !x !ENDDEFINE.
1934 DEFINE !d() !LET !x y !ENDDEFINE.
1941 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1942 define.sps:1: In the expansion of `!a',
1943 define.sps:6.1-6.2: error: DEBUG EXPAND: Expected macro variable name following
1948 define.sps:2: At `0' in the expansion of `!b',
1949 define.sps:7.1-7.2: error: DEBUG EXPAND: Expected macro variable name following
1954 define.sps:3: In the expansion of `!c',
1955 define.sps:8.1-8.2: error: DEBUG EXPAND: Expected `=' following !LET.
1959 define.sps:4: At `y' in the expansion of `!d',
1960 define.sps:9.1-9.2: error: DEBUG EXPAND: Expected `=' following !LET.
1966 AT_SETUP([macro !DO errors])
1968 AT_DATA([define.sps], [dnl
1969 DEFINE !a() !DO !ENDDEFINE.
1970 DEFINE !b() !DO 0 !ENDDEFINE.
1971 DEFINE !c() !DO !x !ENDDEFINE.
1972 DEFINE !d() !DO !x !in (x) !ENDDEFINE.
1973 DEFINE !e() !DO !x = x. !ENDDEFINE.
1974 DEFINE !f() !DO !x = 5 x !ENDDEFINE.
1975 DEFINE !g() !DO !x = 5 !TO 6 !BY 0 !ENDDEFINE.
1976 DEFINE !h() !DO !x !ENDDEFINE.
1977 DEFINE !i() !DO !x 0 !ENDDEFINE.
1978 DEFINE !j() !BREAK !ENDDEFINE.
1991 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1992 define.sps:1: In the expansion of `!a',
1993 define.sps:12.1-12.2: error: DEBUG EXPAND: Expected macro variable name
1998 define.sps:2: At `0' in the expansion of `!b',
1999 define.sps:13.1-13.2: error: DEBUG EXPAND: Expected macro variable name
2004 define.sps:3: In the expansion of `!c',
2005 define.sps:14.1-14.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2009 In the expansion of `!DO',
2010 define.sps:4: inside the expansion of `!d',
2011 define.sps:15.1-15.2: error: DEBUG EXPAND: Missing !DOEND.
2015 At `x' in the expansion of `!DO',
2016 define.sps:5: inside the expansion of `!e',
2017 define.sps:16.1-16.2: error: DEBUG EXPAND: Macro expression must evaluate to a
2022 At `x' in the expansion of `!DO',
2023 define.sps:6: inside the expansion of `!f',
2024 define.sps:17.1-17.2: error: DEBUG EXPAND: Expected !TO in numerical !DO loop.
2028 In the expansion of `!DO',
2029 define.sps:7: inside the expansion of `!g',
2030 define.sps:18.1-18.2: error: DEBUG EXPAND: !BY value cannot be zero.
2032 !DO !x = 5 !TO 6 !BY 0
2034 define.sps:8: In the expansion of `!h',
2035 define.sps:19.1-19.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2039 define.sps:9: At `0' in the expansion of `!i',
2040 define.sps:20.1-20.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2044 define.sps:10: At `!BREAK' in the expansion of `!j',
2045 define.sps:21.1-21.2: error: DEBUG EXPAND: !BREAK outside !DO.
2050 AT_SETUP([macros in comments])
2051 AT_KEYWORDS([macro])
2052 AT_DATA([define.sps], [dnl
2053 DEFINE !macro() x y z !ENDDEFINE.
2059 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
2064 AT_SETUP([DEFINE syntax errors])
2065 AT_KEYWORDS([macro])
2066 AT_DATA([define.sps], [dnl
2067 DEFINE !macro(!POSITIONAL !CHAREND('x y')) !ENDDEFINE.
2068 DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2069 DEFINE !macro(!a=!TOKENS(1)) !ENDDEFINE.
2070 DEFINE !macro(do=!TOKENS(1)) !ENDDEFINE.
2071 DEFINE 0() !ENDDEFINE.
2072 DEFINE x y () !ENDDEFINE.
2073 DEFINE !macro(1) !ENDDEFINE.
2074 DEFINE !macro(x 2) !ENDDEFINE.
2075 DEFINE !macro(x=!DEFAULT 3) !ENDDEFINE.
2076 DEFINE !macro(x=!TOKENS 4) !ENDDEFINE.
2077 DEFINE !macro(x=!TOKENS(x)) !ENDDEFINE.
2078 DEFINE !macro(x=!TOKENS(1 5)) !ENDDEFINE.
2079 DEFINE !macro(x=!ENCLOSE 6) !ENDDEFINE.
2080 DEFINE !macro(x=!ENCLOSE('x' y)) !ENDDEFINE.
2081 DEFINE !macro(x=!ENCLOSE('x',y)) !ENDDEFINE.
2082 DEFINE !macro(x=!ENCLOSE('x','y' z)) !ENDDEFINE.
2083 DEFINE !macro(x=!CHAREND 7) !ENDDEFINE.
2084 DEFINE !macro(x=!CHAREND(8)) !ENDDEFINE.
2085 DEFINE !macro(x=!CHAREND('x' 9)) !ENDDEFINE.
2086 DEFINE !macro(x=!WTF) !ENDDEFINE.
2087 DEFINE !macro(x=!TOKENS(1) x) !ENDDEFINE.
2088 DEFINE !macro(x=!DEFAULT() !DEFAULT()) !ENDDEFINE.
2089 DEFINE !macro(x=!TOKENS(1) !CMDEND) !ENDDEFINE.
2092 AT_CHECK([pspp define.sps], [1], [dnl
2093 define.sps:1.36-1.40: error: DEFINE: Syntax error at `'x y'': String must
2094 contain exactly one token.
2096 define.sps:2.40-2.46: error: DEFINE: Syntax error at `!TOKENS': Positional
2097 parameters must precede keyword parameters.
2099 define.sps:3.15-3.16: error: DEFINE: Syntax error at `!a': Keyword macro
2100 parameter must be named in definition without "!" prefix.
2102 define.sps:4.15-4.16: error: DEFINE: Syntax error at `do': Cannot use macro
2103 keyword "do" as an argument name.
2105 define.sps:5.8: error: DEFINE: Syntax error at `0': expecting identifier.
2107 define.sps:6.10: error: DEFINE: Syntax error at `y': expecting `@{:@'.
2109 define.sps:7.15: error: DEFINE: Syntax error at `1': expecting identifier.
2111 define.sps:8.17: error: DEFINE: Syntax error at `2': expecting !TOKENS, !
2112 CHAREND, !ENCLOSE, or !CMDEND.
2114 define.sps:9.26: error: DEFINE: Syntax error at `3': expecting `@{:@'.
2116 define.sps:10.25: error: DEFINE: Syntax error at `4': expecting `('.
2118 define.sps:11.25: error: DEFINE: Syntax error at `x': Expected positive integer
2121 define.sps:12.27: error: DEFINE: Syntax error at `5': expecting `)'.
2123 define.sps:13.26: error: DEFINE: Syntax error at `6': expecting `('.
2125 define.sps:14.30: error: DEFINE: Syntax error at `y': expecting `,'.
2127 define.sps:15.30: error: DEFINE: Syntax error at `y': expecting string.
2129 define.sps:16.34: error: DEFINE: Syntax error at `z': expecting `)'.
2131 define.sps:17.26: error: DEFINE: Syntax error at `7': expecting `('.
2133 define.sps:18.26: error: DEFINE: Syntax error at `8': expecting string.
2135 define.sps:19.30: error: DEFINE: Syntax error at `9': expecting `)'.
2137 define.sps:20.17-20.20: error: DEFINE: Syntax error at `!WTF': expecting !
2138 TOKENS, !CHAREND, !ENCLOSE, or !CMDEND.
2140 define.sps:21.28: error: DEFINE: Syntax error at `x': expecting `/'.
2142 define.sps:22.36: error: DEFINE: Syntax error at `(': !DEFAULT is allowed only
2145 define.sps:23.35: error: DEFINE: Syntax error at `)': Only one of !TOKENS, !
2146 CHAREND, !ENCLOSE, or !CMDEND is allowed.
2148 define.sps:25.1: error: DEFINE: Syntax error at end of command: Expecting macro
2153 AT_SETUP([macro expansion with token merging])
2154 AT_DATA([define.sps], [dnl
2155 DEFINE !foo() "foo" !ENDDEFINE.
2156 DEFINE !bar() "bar" !ENDDEFINE.
2157 DEFINE !plus() + !ENDDEFINE.
2158 DEFINE !minus() - !ENDDEFINE.
2159 DEFINE !one() 1 !ENDDEFINE.
2166 ECHO !foo !plus !bar.
2167 ECHO "two" "strings".
2169 N OF CASES !minus 1.
2171 N OF CASES !minus !one.
2173 AT_CHECK([pspp define.sps], [1], [dnl
2190 define.sps:13.12-13.20: error: ECHO: Syntax error at `"strings"': expecting end
2193 define.sps:14.12-14.17: error: N OF CASES: Syntax error at `-/**/1': Expected
2194 positive integer for N OF CASES.
2196 define.sps:15.12-15.19: error: N OF CASES: Syntax error at `!minus 1': Expected
2197 positive integer for N OF CASES.
2199 define.sps:16.12-16.17: error: N OF CASES: Syntax error at `- !one': Expected
2200 positive integer for N OF CASES.
2202 define.sps:17.12-17.22: error: N OF CASES: Syntax error at `!minus !one':
2203 Expected positive integer for N OF CASES.
2207 AT_SETUP([one macro calls another])
2208 AT_DATA([define.sps], [dnl
2209 DEFINE !a(!pos !enclose('(',')')) [[!1]] !ENDDEFINE.
2210 DEFINE !b(!pos !enclose('{','}')) !a(x !1 z) !ENDDEFINE.
2211 DEFINE !c(!pos !enclose('{','}')) !let !tmp=!quote(!concat('<',!1,'>')) !a(!tmp) !ENDDEFINE.
2216 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl