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.
510 define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more
511 token in argument !arg1 to macro !k.
517 AT_SETUP([macro expansion - !CHAREND keyword arguments])
518 AT_KEYWORDS([CHAREND])
519 AT_DATA([define.sps], [dnl
520 DEFINE !k(arg1 = !CHAREND('/')
521 /arg2 = !CHAREND('/'))
530 AT_CAPTURE_FILE([define.sps])
531 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
542 AT_SETUP([macro expansion - !CHAREND keyword arguments - negative])
543 AT_KEYWORDS([CHAREND])
544 AT_DATA([define.sps], [dnl
545 DEFINE !k(arg1 = !CHAREND('/')
546 /arg2 = !CHAREND('/'))
555 AT_CAPTURE_FILE([define.sps])
556 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
557 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
558 argument !arg1 to macro !k.
562 define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in
563 argument !arg1 to macro !k.
567 define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in
568 argument !arg1 to macro !k.
572 define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in
573 argument !arg2 to macro !k.
579 AT_SETUP([macro expansion - !ENCLOSE keyword arguments])
580 AT_KEYWORDS([ENCLOSE])
581 AT_DATA([define.sps], [dnl
582 DEFINE !k(arg1 = !ENCLOSE('(',')')
583 /arg2 = !ENCLOSE('{','}'))
587 !k arg1=(x) arg2={y}.
592 AT_CAPTURE_FILE([define.sps])
593 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
604 AT_SETUP([macro expansion - !ENCLOSE keyword arguments - negative])
605 AT_KEYWORDS([ENCLOSE])
606 AT_DATA([define.sps], [dnl
607 DEFINE !k(arg1 = !ENCLOSE('(',')')
608 /arg2 = !ENCLOSE('{','}'))
621 AT_CAPTURE_FILE([define.sps])
622 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
623 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
624 argument !arg1 to macro !k.
628 define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading
629 argument !arg1 to macro !k.
633 define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading
634 argument !arg1 to macro !k.
638 note: unexpanded token "x"
640 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "@:}@" in
641 argument !arg1 to macro !k.
645 define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading
646 argument !arg2 to macro !k.
650 define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading
651 argument !arg2 to macro !k.
655 define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading
656 argument !arg2 to macro !k.
660 note: unexpanded token "y"
662 define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading
663 argument !arg2 to macro !k.
667 note: unexpanded token "@{:@"
669 note: unexpanded token "y"
673 dnl Keep this test in sync with the examples for !BLANKS in the manual.
674 AT_SETUP([macro expansion - !BLANKS])
675 AT_KEYWORDS([BLANKS])
676 AT_DATA([define.sps], [dnl
690 AT_CAPTURE_FILE([define.sps])
691 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
703 dnl Keep this test in sync with the examples for !CONCAT in the manual.
704 AT_SETUP([macro expansion - !CONCAT])
705 AT_KEYWORDS([CONCAT])
706 AT_DATA([define.sps], [dnl
720 AT_CAPTURE_FILE([define.sps])
721 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
733 dnl Keep this test in sync with the examples for !EVAL in the manual.
734 AT_SETUP([macro expansion - !EVAL])
736 AT_DATA([define.sps], [dnl
737 DEFINE !vars() a b c !ENDDEFINE.
743 !QUOTE(!EVAL(!vars)).
746 DEFINE !e2(!positional !enclose('(',')'))
756 AT_CAPTURE_FILE([define.sps])
757 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
770 dnl Keep this test in sync with the examples for !HEAD in the manual.
771 AT_SETUP([macro expansion - !HEAD])
773 AT_DATA([define.sps], [dnl
783 AT_CAPTURE_FILE([define.sps])
784 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
792 dnl Keep this test in sync with the examples for !TAIL in the manual.
793 AT_SETUP([macro expansion - !TAIL])
795 AT_DATA([define.sps], [dnl
805 AT_CAPTURE_FILE([define.sps])
806 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
814 dnl Keep this test in sync with the examples for !INDEX in the manual.
815 AT_SETUP([macro expansion - !INDEX])
817 AT_DATA([define.sps], [dnl
821 !INDEX(banana, apple).
822 !INDEX("banana", nan).
823 !INDEX("banana", "nan").
824 !INDEX(!UNQUOTE("banana"), !UNQUOTE("nan")).
829 AT_CAPTURE_FILE([define.sps])
830 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
840 dnl Keep this test in sync with the examples for !LENGTH in the manual.
841 AT_SETUP([macro expansion - !LENGTH])
842 AT_KEYWORDS([LENGTH])
843 AT_DATA([define.sps], [dnl
852 !LENGTH(!UNQUOTE("xyzzy")).
853 !LENGTH(!UNQUOTE("xy""zzy")).
856 DEFINE !la(!positional !enclose('(',')'))
864 AT_CAPTURE_FILE([define.sps])
865 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
883 dnl Keep this test in sync with the examples for !SUBSTR in the manual.
884 AT_SETUP([macro expansion - !SUBSTR])
885 AT_KEYWORDS([SUBSTR])
886 AT_DATA([define.sps], [dnl
889 !SUBSTR(banana, 3, 3).
890 !SUBSTR("banana", 1, 3).
891 !SUBSTR(!UNQUOTE("banana"), 3).
892 !SUBSTR("banana", 3, 3).
893 !SUBSTR(banana, 3, 0).
894 !SUBSTR(banana, 3, 10).
895 !SUBSTR(banana, 10, 3).
900 AT_CAPTURE_FILE([define.sps])
901 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
902 define.sps:1-10: At `"ba' in the expansion of `!s',dnl "
904 define.sps:12.1-12.2: error: DEBUG EXPAND: Unterminated string constant.
917 dnl Keep this test in sync with the examples for !UPCASE in the manual.
918 AT_SETUP([macro expansion - !UPCASE])
919 AT_KEYWORDS([UPCASE])
920 AT_DATA([define.sps], [dnl
930 AT_CAPTURE_FILE([define.sps])
931 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
939 dnl !* is implemented separately inside and outside function arguments
940 dnl so this test makes sure to include both.
941 AT_SETUP([macro expansion - !*])
942 AT_DATA([define.sps], [dnl
943 DEFINE !m(!POSITIONAL !TOKENS(1)
944 /!POSITIONAL !TOKENS(1))
955 AT_CAPTURE_FILE([define.sps])
956 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
957 123 b / 5 / 3 b / '123 b'.
961 '' 'b' / 6 / 'b' / ''''' ''b'''.
965 AT_SETUP([macro maximum nesting level (MNEST)])
967 AT_DATA([define.sps], [dnl
973 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
974 "define.sps:1-3: In the expansion of `!macro',
975 define.sps:1-3: inside the expansion of `!macro',
976 define.sps:1-3: inside the expansion of `!macro',
977 define.sps:1-3: inside the expansion of `!macro',
978 define.sps:1-3: inside the expansion of `!macro',
979 define.sps:1-3: inside the expansion of `!macro',
980 define.sps:1-3: inside the expansion of `!macro',
981 define.sps:1-3: inside the expansion of `!macro',
982 define.sps:1-3: inside the expansion of `!macro',
983 define.sps:1-3: inside the expansion of `!macro',
984 define.sps:1-3: inside the expansion of `!macro',
985 define.sps:1-3: inside the expansion of `!macro',
986 define.sps:1-3: inside the expansion of `!macro',
987 define.sps:1-3: inside the expansion of `!macro',
988 define.sps:1-3: inside the expansion of `!macro',
989 define.sps:1-3: inside the expansion of `!macro',
990 define.sps:1-3: inside the expansion of `!macro',
991 define.sps:1-3: inside the expansion of `!macro',
992 define.sps:1-3: inside the expansion of `!macro',
993 define.sps:1-3: inside the expansion of `!macro',
994 define.sps:1-3: inside the expansion of `!macro',
995 define.sps:1-3: inside the expansion of `!macro',
996 define.sps:1-3: inside the expansion of `!macro',
997 define.sps:1-3: inside the expansion of `!macro',
998 define.sps:1-3: inside the expansion of `!macro',
999 define.sps:1-3: inside the expansion of `!macro',
1000 define.sps:1-3: inside the expansion of `!macro',
1001 define.sps:1-3: inside the expansion of `!macro',
1002 define.sps:1-3: inside the expansion of `!macro',
1003 define.sps:1-3: inside the expansion of `!macro',
1004 define.sps:1-3: inside the expansion of `!macro',
1005 define.sps:1-3: inside the expansion of `!macro',
1006 define.sps:1-3: inside the expansion of `!macro',
1007 define.sps:1-3: inside the expansion of `!macro',
1008 define.sps:1-3: inside the expansion of `!macro',
1009 define.sps:1-3: inside the expansion of `!macro',
1010 define.sps:1-3: inside the expansion of `!macro',
1011 define.sps:1-3: inside the expansion of `!macro',
1012 define.sps:1-3: inside the expansion of `!macro',
1013 define.sps:1-3: inside the expansion of `!macro',
1014 define.sps:1-3: inside the expansion of `!macro',
1015 define.sps:1-3: inside the expansion of `!macro',
1016 define.sps:1-3: inside the expansion of `!macro',
1017 define.sps:1-3: inside the expansion of `!macro',
1018 define.sps:1-3: inside the expansion of `!macro',
1019 define.sps:1-3: inside the expansion of `!macro',
1020 define.sps:1-3: inside the expansion of `!macro',
1021 define.sps:1-3: inside the expansion of `!macro',
1022 define.sps:1-3: inside the expansion of `!macro',
1023 define.sps:1-3: inside the expansion of `!macro',
1024 define.sps:1-3: inside the expansion of `!macro',
1025 define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.)"
1027 define.sps:4.1-4.6: error: Syntax error at `!macro' (in expansion of `!macro'): expecting command name.
1031 AT_SETUP([macro !IF condition])
1034 '!eq !ne !lt !gt !le !ge' \
1038 AS_BOX([$operators])
1039 cat > define.sps <<EOF
1040 DEFINE !test(!positional !tokens(1))
1041 !if (!1 $1 1) !then true !else false !ifend
1042 !if (!1 $2 1) !then true !else false !ifend
1043 !if (!1 $3 1) !then true !else false !ifend
1044 !if (!1 $4 1) !then true !else false !ifend
1045 !if (!1 $5 1) !then true !else false !ifend
1046 !if (!1 $6 1) !then true !else false !ifend.
1055 AT_CAPTURE_FILE([define.sps])
1056 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1057 false true true false true false.
1059 true false false false true true.
1061 false true false true false true.
1063 true false false false true true.
1065 false true false true false true.
1070 AT_SETUP([macro !IF condition -- case sensitivity])
1073 '!eq !ne !lt !gt !le !ge' \
1077 AS_BOX([$operators])
1078 cat > define.sps <<EOF
1079 DEFINE !test(!positional !tokens(1))
1080 !if (!1 $1 a) !then true !else false !ifend
1081 !if (!1 $1 A) !then true !else false !ifend
1082 !if (!1 $2 a) !then true !else false !ifend
1083 !if (!1 $2 A) !then true !else false !ifend
1084 !if (!1 $3 a) !then true !else false !ifend
1085 !if (!1 $3 A) !then true !else false !ifend
1086 !if (!1 $4 a) !then true !else false !ifend
1087 !if (!1 $4 A) !then true !else false !ifend
1088 !if (!1 $5 a) !then true !else false !ifend
1089 !if (!1 $5 A) !then true !else false !ifend
1090 !if (!1 $6 a) !then true !else false !ifend
1091 !if (!1 $6 A) !then true !else false !ifend
1092 !if (!1 $1 !null) !then true !else false !ifend
1093 !if (!1 $2 !null) !then true !else false !ifend.
1101 AT_CAPTURE_FILE([define.sps])
1102 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1103 true false false true false false false true true false true true false true.
1105 false true true false true false false false true true false true false true.
1107 false false true true false false true true false false true true false true.
1109 false false true true true false false true true false false true false true.
1114 AT_SETUP([macro !IF condition -- logical operators])
1121 AS_BOX([$operators])
1122 cat > define.sps <<EOF
1123 DEFINE !test_binary(!positional !tokens(1)/!positional !tokens(1))
1124 !if !1 $1 !2 !then true !else false !ifend
1125 !if !1 $2 !2 !then true !else false !ifend.
1128 DEFINE !test_unary(!positional !tokens(1))
1129 !if $3 !1 !then true !else false !ifend.
1133 ((not A) and B) or C
1136 DEFINE !test_prec(!pos !tokens(1)/!pos !tokens(1)/!pos !tokens(1))
1137 !if $3 !1 $1 !2 $2 !3 !then true !else false !ifend
1138 !if $3 (!1 $1 !2) $2 !3 !then true !else false !ifend
1139 !if $3 !1 $1 (!2 $2 !3) !then true !else false !ifend
1149 !test_prec 0 0 0 !test_prec 0 0 1 !test_prec 0 1 0 !test_prec 0 1 1.
1150 !test_prec 1 0 0 !test_prec 1 0 1 !test_prec 1 1 0 !test_prec 1 1 1.
1152 AT_CAPTURE_FILE([define.sps])
1153 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1179 AT_SETUP([macro !LET])
1181 AT_DATA([define.sps], [dnl
1182 DEFINE !macro(!POS !CMDEND)
1183 !LET !v1 = !CONCAT('x',!1,'y')
1184 !LET !v2 = !QUOTE(!v1)
1185 !LET !v3 = (!LENGTH(!1) = 1)
1186 !LET !v4 = (!SUBSTR(!1, 3) = !NULL)
1197 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1215 AT_SETUP([macro indexed !DO])
1216 AT_KEYWORDS([index do])
1217 AT_DATA([define.sps], [dnl
1218 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1220 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1221 !DO !var = !1 !TO !2 !var !DOEND.
1224 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1225 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1229 !title "increasing".
1236 !title "decreasing".
1243 !title "non-integer".
1246 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1277 AT_SETUP([macro !DO invalid variable names])
1278 AT_KEYWORDS([index do])
1279 AT_DATA([define.sps], [dnl
1280 DEFINE !for(x=!TOKENS(1) / y=!TOKENS(1))
1281 !DO !x = !x !TO !y !var !DOEND.
1284 DEFINE !for2(x=!TOKENS(1) / y=!TOKENS(1))
1285 !DO !noexpand = !x !TO !y !var !DOEND.
1292 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1293 define.sps:1-3: At `!x' in the expansion of `!for',
1294 define.sps:10.1-10.12: error: DEBUG EXPAND: Cannot use argument name or macro
1295 keyword as !DO variable.
1297 !DO 1 = 1 !TO 5 !var !DOEND.
1299 define.sps:5-7: At `!noexpand' in the expansion of `!for2',
1300 define.sps:11.1-11.13: error: DEBUG EXPAND: Cannot use argument name or macro
1301 keyword as !DO variable.
1303 !DO !noexpand = 1 !TO 5 !var !DOEND.
1307 AT_SETUP([macro indexed !DO reaches MITERATE])
1308 AT_KEYWORDS([index do])
1309 AT_DATA([define.sps], [dnl
1310 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1312 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1313 !DO !var = !1 !TO !2 !var !DOEND.
1316 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1317 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1322 !title "increasing".
1329 !title "decreasing".
1336 !title "non-integer".
1339 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1342 In the expansion of `!DO',
1343 define.sps:3-5: inside the expansion of `!for',
1344 define.sps:14.1-14.8: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1345 number of iterations 3. (Use SET MITERATE to change the limit.)
1349 In the expansion of `!DO',
1350 define.sps:7-9: inside the expansion of `!forby',
1351 define.sps:15.1-15.12: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1352 number of iterations 3. (Use SET MITERATE to change the limit.)
1368 In the expansion of `!DO',
1369 define.sps:7-9: inside the expansion of `!forby',
1370 define.sps:23.1-23.13: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1371 number of iterations 3. (Use SET MITERATE to change the limit.)
1385 AT_SETUP([!BREAK with macro indexed !DO])
1386 AT_KEYWORDS([index do break])
1387 AT_DATA([define.sps], [dnl
1388 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1390 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1391 !DO !var = !1 !TO !2
1407 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1412 AT_SETUP([macro list !DO])
1413 AT_KEYWORDS([index do])
1414 AT_DATA([define.sps], [dnl
1415 DEFINE !for(!POS !CMDEND)
1416 (!DO !i !IN (!1) (!i) !DOEND).
1421 !for 'foo bar baz quux'.
1424 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1427 ( (foo) (bar) (baz) (quux) ).
1433 AT_SETUP([macro list !DO reaches MITERATE])
1434 AT_KEYWORDS([index do])
1435 AT_DATA([define.sps], [dnl
1436 DEFINE !for(!POS !CMDEND)
1437 (!DO !i !IN (!1) (!i) !DOEND).
1443 !for 'foo bar baz quux'.
1446 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1447 In the expansion of `!DO',
1448 define.sps:1-3: inside the expansion of `!for',
1449 define.sps:7.1-7.10: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1450 number of iterations 2. (Use SET MITERATE to change the limit.)
1454 In the expansion of `!DO',
1455 define.sps:1-3: inside the expansion of `!for',
1456 define.sps:8.1-8.23: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1457 number of iterations 2. (Use SET MITERATE to change the limit.)
1465 AT_SETUP([!BREAK with macro list !DO])
1466 AT_KEYWORDS([index break do])
1467 AT_DATA([define.sps], [dnl
1468 DEFINE !for(!POS !TOKENS(1) / !POS !CMDEND)
1484 !for baz 'foo bar baz quux'.
1487 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1490 ( (foo), (bar), (baz)x).
1496 AT_SETUP([macro !LET])
1497 AT_DATA([define.sps], [dnl
1498 DEFINE !macro(!pos !enclose('(',')'))
1509 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl
1516 AT_SETUP([macro !LET invalid variable names])
1517 AT_DATA([define.sps], [dnl
1518 DEFINE !macro(x=!tokens(1))
1530 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [1], [dnl
1531 "define.sps:1-3: At `!x' in the expansion of `!macro',
1532 define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable."
1536 "define.sps:5-7: At `!do' in the expansion of `!macro2',
1537 define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable."
1539 "define.sps:5-7: At `=' in the expansion of `!macro2',
1540 define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO."
1546 AT_SETUP([BEGIN DATA inside a macro])
1547 AT_DATA([define.sps], [dnl
1549 DATA LIST NOTABLE /x 1.
1560 AT_CHECK([pspp define.sps -O format=csv], [0], [dnl
1569 AT_SETUP([TITLE and SUBTITLE with macros])
1570 AT_KEYWORDS([macro])
1571 for command in TITLE SUBTITLE; do
1572 cat >title.sps <<EOF
1573 DEFINE !paste(!POS !TOKENS(1) / !POS !TOKENS(1))
1576 $command prefix !paste foo bar suffix.
1580 title.sps:5: note: SHOW: $command is prefix foobar suffix.
1582 AT_CHECK([pspp -O format=csv title.sps], [0], [expout])
1586 AT_SETUP([error message within macro expansion])
1587 AT_DATA([define.sps], [dnl
1588 DEFINE !vars(!POS !TOKENS(1)) a b C !ENDDEFINE.
1589 DATA LIST NOTABLE /a b 1-2.
1590 COMPUTE x = !vars x.
1592 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1593 define.sps:3.13-3.19: error: COMPUTE: Syntax error at `b' (in expansion of `!vars x'): expecting end of command.
1597 dnl A macro with keyword arguments needs a token of lookahead
1598 dnl to find out whether another keyword is present. Test that
1599 dnl this special case works OK.
1600 AT_SETUP([macro calls in each others' lookahead])
1601 AT_DATA([define.sps], [dnl
1602 DEFINE !k(x=!DEFAULT(0) !TOKENS(1)/y=!DEFAULT(0) !TOKENS(1))
1612 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1624 AT_SETUP([bad token in macro body])
1625 AT_DATA([define.sps], [dnl
1630 AT_CHECK([pspp define.sps], [1], [dnl
1631 define.sps:3: error: DEFINE: String of hex digits has 3 characters, which is
1632 not a multiple of 2.
1636 AT_SETUP([generic macro function syntax errors])
1637 AT_DATA([define.sps], [dnl
1638 DEFINE !a() !SUBSTR !ENDDEFINE.
1639 DEFINE !b() !SUBSTR x !ENDDEFINE.
1640 DEFINE !c() !SUBSTR(1x) !ENDDEFINE.
1641 DEFINE !d() !SUBSTR(1 !ENDDEFINE.
1642 DEFINE !narg_blanks() !BLANKS() !ENDDEFINE.
1643 DEFINE !narg_concat() !CONCAT() !ENDDEFINE.
1644 DEFINE !narg_eval() !EVAL() !ENDDEFINE.
1645 DEFINE !narg_head() !HEAD() !ENDDEFINE.
1646 DEFINE !narg_index() !INDEX() !ENDDEFINE.
1647 DEFINE !narg_length() !LENGTH() !ENDDEFINE.
1648 DEFINE !narg_null() !NULL() !ENDDEFINE.
1649 DEFINE !narg_quote() !QUOTE() !ENDDEFINE.
1650 DEFINE !narg_substr() !SUBSTR() !ENDDEFINE.
1651 DEFINE !narg_tail() !TAIL() !ENDDEFINE.
1652 DEFINE !narg_unquote() !UNQUOTE() !ENDDEFINE.
1653 DEFINE !narg_upcase() !UPCASE() !ENDDEFINE.
1673 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1674 define.sps:1: In the expansion of `!a',
1675 define.sps:18.1-18.2: error: DEBUG EXPAND: `@{:@' expected following !SUBSTR.
1679 define.sps:2: At `x' in the expansion of `!b',
1680 define.sps:19.1-19.2: error: DEBUG EXPAND: `@{:@' expected following !SUBSTR.
1684 define.sps:3: At `x' in the expansion of `!c',
1685 define.sps:20.1-20.2: error: DEBUG EXPAND: `,' or `@:}@' expected in call to macro
1690 define.sps:4: In the expansion of `!d',
1691 define.sps:21.1-21.2: error: DEBUG EXPAND: Missing `@:}@' in call to macro
1696 define.sps:5: In the expansion of `!narg_blanks',
1697 define.sps:22.1-22.12: error: DEBUG EXPAND: Macro function !BLANKS takes one
1702 define.sps:6: In the expansion of `!narg_concat',
1703 define.sps:23.1-23.12: error: DEBUG EXPAND: Macro function !CONCAT needs at
1708 define.sps:7: In the expansion of `!narg_eval',
1709 define.sps:24.1-24.10: error: DEBUG EXPAND: Macro function !EVAL takes one
1714 define.sps:8: In the expansion of `!narg_head',
1715 define.sps:25.1-25.10: error: DEBUG EXPAND: Macro function !HEAD takes one
1720 define.sps:9: In the expansion of `!narg_index',
1721 define.sps:26.1-26.11: error: DEBUG EXPAND: Macro function !INDEX takes two
1726 define.sps:10: In the expansion of `!narg_length',
1727 define.sps:27.1-27.12: error: DEBUG EXPAND: Macro function !LENGTH takes one
1734 define.sps:12: In the expansion of `!narg_quote',
1735 define.sps:29.1-29.11: error: DEBUG EXPAND: Macro function !QUOTE takes one
1740 define.sps:13: In the expansion of `!narg_substr',
1741 define.sps:30.1-30.12: error: DEBUG EXPAND: Macro function !SUBSTR takes two or
1742 three arguments (not 0).
1746 define.sps:14: In the expansion of `!narg_tail',
1747 define.sps:31.1-31.10: error: DEBUG EXPAND: Macro function !TAIL takes one
1752 define.sps:15: In the expansion of `!narg_unquote',
1753 define.sps:32.1-32.13: error: DEBUG EXPAND: Macro function !UNQUOTE takes one
1758 define.sps:16: In the expansion of `!narg_upcase',
1759 define.sps:33.1-33.12: error: DEBUG EXPAND: Macro function !UPCASE takes one
1766 AT_SETUP([specific macro function syntax errors])
1767 AT_DATA([define.sps], [dnl
1768 DEFINE !a() !BLANKS(x). !ENDDEFINE.
1769 DEFINE !b() !SUBSTR(x, y). !ENDDEFINE.
1770 DEFINE !c() !SUBSTR(x, 1, z). !ENDDEFINE.
1776 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1777 define.sps:1: In the expansion of `!a',
1778 define.sps:5.1-5.2: error: DEBUG EXPAND: Argument to !BLANKS must be non-
1779 negative integer (not "x").
1783 define.sps:2: In the expansion of `!b',
1784 define.sps:6.1-6.2: error: DEBUG EXPAND: Second argument of !SUBSTR must be
1785 positive integer (not "y").
1789 define.sps:3: In the expansion of `!c',
1790 define.sps:7.1-7.2: error: DEBUG EXPAND: Third argument of !SUBSTR must be non-
1791 negative integer (not "z").
1797 AT_SETUP([macro expression errors])
1798 AT_DATA([define.sps], [dnl
1799 DEFINE !a() !LET !x = (1. !ENDDEFINE dnl )
1801 DEFINE !b() !DO !x = x. !ENDDEFINE.
1802 DEFINE !c() !LET !x = (). !ENDDEFINE.
1808 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1809 define.sps:1-2: At `.' in the expansion of `!a',
1810 define.sps:5.1-5.2: error: DEBUG EXPAND: Expecting ')' in macro expression.
1814 At `x' in the expansion of `!DO',
1815 define.sps:2: inside the expansion of `!b',
1816 define.sps:6.1-6.2: error: DEBUG EXPAND: Macro expression must evaluate to a
1821 define.sps:3: At `)' in the expansion of `!c',
1822 define.sps:7.1-7.2: error: DEBUG EXPAND: Expecting literal or function
1823 invocation in macro expression.
1829 AT_SETUP([macro !IF errors])
1831 AT_DATA([define.sps], [dnl
1832 DEFINE !a() !IF 1 !ENDDEFINE.
1833 DEFINE !b() !IF 1 !THEN !ENDDEFINE.
1834 DEFINE !c() !IF 1 !THEN !ELSE !ENDDEFINE.
1840 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1841 define.sps:1: In the expansion of `!a',
1842 define.sps:5.1-5.2: error: DEBUG EXPAND: !THEN expected in macro !IF construct.
1846 define.sps:2: In the expansion of `!b',
1847 define.sps:6.1-6.2: error: DEBUG EXPAND: !ELSE or !IFEND expected in macro !IF
1852 define.sps:3: In the expansion of `!c',
1853 define.sps:7.1-7.2: error: DEBUG EXPAND: !IFEND expected in macro !IF
1860 AT_SETUP([macro !LET errors])
1862 AT_DATA([define.sps], [dnl
1863 DEFINE !a() !LET !ENDDEFINE.
1864 DEFINE !b() !LET 0 !ENDDEFINE.
1865 DEFINE !c() !LET !x !ENDDEFINE.
1866 DEFINE !d() !LET !x y !ENDDEFINE.
1873 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1874 define.sps:1: In the expansion of `!a',
1875 define.sps:6.1-6.2: error: DEBUG EXPAND: Expected macro variable name following
1880 define.sps:2: At `0' in the expansion of `!b',
1881 define.sps:7.1-7.2: error: DEBUG EXPAND: Expected macro variable name following
1886 define.sps:3: In the expansion of `!c',
1887 define.sps:8.1-8.2: error: DEBUG EXPAND: Expected `=' following !LET.
1891 define.sps:4: At `y' in the expansion of `!d',
1892 define.sps:9.1-9.2: error: DEBUG EXPAND: Expected `=' following !LET.
1898 AT_SETUP([macro !DO errors])
1900 AT_DATA([define.sps], [dnl
1901 DEFINE !a() !DO !ENDDEFINE.
1902 DEFINE !b() !DO 0 !ENDDEFINE.
1903 DEFINE !c() !DO !x !ENDDEFINE.
1904 DEFINE !d() !DO !x !in (x) !ENDDEFINE.
1905 DEFINE !e() !DO !x = x. !ENDDEFINE.
1906 DEFINE !f() !DO !x = 5 x !ENDDEFINE.
1907 DEFINE !g() !DO !x = 5 !TO 6 !BY 0 !ENDDEFINE.
1908 DEFINE !h() !DO !x !ENDDEFINE.
1909 DEFINE !i() !DO !x 0 !ENDDEFINE.
1910 DEFINE !j() !BREAK !ENDDEFINE.
1923 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1924 define.sps:1: In the expansion of `!a',
1925 define.sps:12.1-12.2: error: DEBUG EXPAND: Expected macro variable name
1930 define.sps:2: At `0' in the expansion of `!b',
1931 define.sps:13.1-13.2: error: DEBUG EXPAND: Expected macro variable name
1936 define.sps:3: In the expansion of `!c',
1937 define.sps:14.1-14.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
1941 In the expansion of `!DO',
1942 define.sps:4: inside the expansion of `!d',
1943 define.sps:15.1-15.2: error: DEBUG EXPAND: Missing !DOEND.
1947 At `x' in the expansion of `!DO',
1948 define.sps:5: inside the expansion of `!e',
1949 define.sps:16.1-16.2: error: DEBUG EXPAND: Macro expression must evaluate to a
1954 At `x' in the expansion of `!DO',
1955 define.sps:6: inside the expansion of `!f',
1956 define.sps:17.1-17.2: error: DEBUG EXPAND: Expected !TO in numerical !DO loop.
1960 In the expansion of `!DO',
1961 define.sps:7: inside the expansion of `!g',
1962 define.sps:18.1-18.2: error: DEBUG EXPAND: !BY value cannot be zero.
1964 !DO !x = 5 !TO 6 !BY 0
1966 define.sps:8: In the expansion of `!h',
1967 define.sps:19.1-19.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
1971 define.sps:9: At `0' in the expansion of `!i',
1972 define.sps:20.1-20.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
1976 define.sps:10: At `!BREAK' in the expansion of `!j',
1977 define.sps:21.1-21.2: error: DEBUG EXPAND: !BREAK outside !DO.
1982 AT_SETUP([macros in comments])
1983 AT_KEYWORDS([macro])
1984 AT_DATA([define.sps], [dnl
1985 DEFINE !macro() x y z !ENDDEFINE.
1991 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1996 AT_SETUP([DEFINE syntax errors])
1997 AT_KEYWORDS([macro])
1998 AT_DATA([define.sps], [dnl
1999 DEFINE !macro(!POSITIONAL !CHAREND('x y')) !ENDDEFINE.
2000 DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2001 DEFINE !macro(!a=!TOKENS(1)) !ENDDEFINE.
2002 DEFINE !macro(do=!TOKENS(1)) !ENDDEFINE.
2003 DEFINE 0() !ENDDEFINE.
2004 DEFINE x y () !ENDDEFINE.
2005 DEFINE !macro(1) !ENDDEFINE.
2006 DEFINE !macro(x 2) !ENDDEFINE.
2007 DEFINE !macro(x=!DEFAULT 3) !ENDDEFINE.
2008 DEFINE !macro(x=!TOKENS 4) !ENDDEFINE.
2009 DEFINE !macro(x=!TOKENS(x)) !ENDDEFINE.
2010 DEFINE !macro(x=!TOKENS(1 5)) !ENDDEFINE.
2011 DEFINE !macro(x=!ENCLOSE 6) !ENDDEFINE.
2012 DEFINE !macro(x=!ENCLOSE('x' y)) !ENDDEFINE.
2013 DEFINE !macro(x=!ENCLOSE('x',y)) !ENDDEFINE.
2014 DEFINE !macro(x=!ENCLOSE('x','y' z)) !ENDDEFINE.
2015 DEFINE !macro(x=!CHAREND 7) !ENDDEFINE.
2016 DEFINE !macro(x=!CHAREND(8)) !ENDDEFINE.
2017 DEFINE !macro(x=!CHAREND('x' 9)) !ENDDEFINE.
2018 DEFINE !macro(x=!WTF) !ENDDEFINE.
2019 DEFINE !macro(x=!TOKENS(1) x) !ENDDEFINE.
2020 DEFINE !macro(x=!DEFAULT() !DEFAULT()) !ENDDEFINE.
2021 DEFINE !macro(x=!TOKENS(1) !CMDEND) !ENDDEFINE.
2024 AT_CHECK([pspp define.sps], [1], [dnl
2025 define.sps:1.36-1.40: error: DEFINE: Syntax error at `'x y'': String must
2026 contain exactly one token.
2028 define.sps:2.40-2.46: error: DEFINE: Syntax error at `!TOKENS': Positional
2029 parameters must precede keyword parameters.
2031 define.sps:3.15-3.16: error: DEFINE: Syntax error at `!a': Keyword macro
2032 parameter must be named in definition without "!" prefix.
2034 define.sps:4.15-4.16: error: DEFINE: Syntax error at `do': Cannot use macro
2035 keyword "do" as an argument name.
2037 define.sps:5.8: error: DEFINE: Syntax error at `0': expecting identifier.
2039 define.sps:6.10: error: DEFINE: Syntax error at `y': expecting `@{:@'.
2041 define.sps:7.15: error: DEFINE: Syntax error at `1': expecting identifier.
2043 define.sps:8.17: error: DEFINE: Syntax error at `2': expecting !TOKENS, !
2044 CHAREND, !ENCLOSE, or !CMDEND.
2046 define.sps:9.26: error: DEFINE: Syntax error at `3': expecting `@{:@'.
2048 define.sps:10.25: error: DEFINE: Syntax error at `4': expecting `('.
2050 define.sps:11.25: error: DEFINE: Syntax error at `x': Expected positive integer
2053 define.sps:12.27: error: DEFINE: Syntax error at `5': expecting `)'.
2055 define.sps:13.26: error: DEFINE: Syntax error at `6': expecting `('.
2057 define.sps:14.30: error: DEFINE: Syntax error at `y': expecting `,'.
2059 define.sps:15.30: error: DEFINE: Syntax error at `y': expecting string.
2061 define.sps:16.34: error: DEFINE: Syntax error at `z': expecting `)'.
2063 define.sps:17.26: error: DEFINE: Syntax error at `7': expecting `('.
2065 define.sps:18.26: error: DEFINE: Syntax error at `8': expecting string.
2067 define.sps:19.30: error: DEFINE: Syntax error at `9': expecting `)'.
2069 define.sps:20.17-20.20: error: DEFINE: Syntax error at `!WTF': expecting !
2070 TOKENS, !CHAREND, !ENCLOSE, or !CMDEND.
2072 define.sps:21.28: error: DEFINE: Syntax error at `x': expecting `/'.
2074 define.sps:22.36: error: DEFINE: Syntax error at `(': !DEFAULT is allowed only
2077 define.sps:23.35: error: DEFINE: Syntax error at `)': Only one of !TOKENS, !
2078 CHAREND, !ENCLOSE, or !CMDEND is allowed.
2080 define.sps:25.1: error: DEFINE: Syntax error at end of command: Expecting macro
2085 AT_SETUP([macro expansion with token merging])
2086 AT_DATA([define.sps], [dnl
2087 DEFINE !foo() "foo" !ENDDEFINE.
2088 DEFINE !bar() "bar" !ENDDEFINE.
2089 DEFINE !plus() + !ENDDEFINE.
2090 DEFINE !minus() - !ENDDEFINE.
2091 DEFINE !one() 1 !ENDDEFINE.
2098 ECHO !foo !plus !bar.
2099 ECHO "two" "strings".
2101 N OF CASES !minus 1.
2103 N OF CASES !minus !one.
2105 AT_CHECK([pspp define.sps], [1], [dnl
2122 define.sps:13.12-13.20: error: ECHO: Syntax error at `"strings"': expecting end
2125 define.sps:14.12-14.17: error: N OF CASES: Syntax error at `-/**/1': Expected
2126 positive integer for N OF CASES.
2128 define.sps:15.12-15.19: error: N OF CASES: Syntax error at `!minus 1': Expected
2129 positive integer for N OF CASES.
2131 define.sps:16.12-16.17: error: N OF CASES: Syntax error at `- !one': Expected
2132 positive integer for N OF CASES.
2134 define.sps:17.12-17.22: error: N OF CASES: Syntax error at `!minus !one':
2135 Expected positive integer for N OF CASES.
2139 AT_SETUP([one macro calls another])
2140 AT_DATA([define.sps], [dnl
2141 DEFINE !a(!pos !enclose('(',')')) [[!1]] !ENDDEFINE.
2142 DEFINE !b(!pos !enclose('{','}')) !a(x !1 z) !ENDDEFINE.
2143 DEFINE !c(!pos !enclose('{','}')) !let !tmp=!quote(!concat('<',!1,'>')) !a(!tmp) !ENDDEFINE.
2148 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl