X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fcontrol%2Fdefine.at;h=fb66b01378429a2984e717d945d1b5e07ab18513;hb=578bc59e7ec144bc8424e9a58807a791314cc0e8;hp=e0687677ecc04056076b44cfbef7d921151f40d9;hpb=9632637a783f8d32ff4d76dca42e3d1bb6a8834b;p=pspp diff --git a/tests/language/control/define.at b/tests/language/control/define.at index e0687677ec..fb66b01378 100644 --- a/tests/language/control/define.at +++ b/tests/language/control/define.at @@ -16,19 +16,6 @@ dnl along with this program. If not, see . dnl AT_BANNER([DEFINE]) -m4_define([PSPP_CHECK_MACRO_EXPANSION], - [AT_SETUP([macro expansion - $1]) - AT_KEYWORDS([m4_bpatsubst([$1], [!], [])]) - AT_DATA([define.sps], [$2 -DEBUG EXPAND. -$3 -]) - AT_CAPTURE_FILE([define.sps]) - AT_DATA([expout], [$4 -]) - AT_CHECK([pspp --testing-mode define.sps | sed '/^$/d'], [$6], [expout]) - AT_CLEANUP]) - AT_SETUP([simple macro expansion]) AT_DATA([define.sps], [dnl DEFINE !macro() @@ -54,15 +41,38 @@ m(n, o). ]) AT_CLEANUP -PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) positional argument], - [DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.], - [!t1 a. +AT_SETUP([redefining a macro]) +AT_DATA([define.sps], [dnl +DEFINE !macro() 0 !ENDDEFINE. +DEFINE !macro() 1 !ENDDEFINE. +DEBUG EXPAND. +!macro. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +1 +]) +AT_CLEANUP + +AT_SETUP([macro expansion - one !TOKENS(1) positional argument]) +AT_KEYWORDS([TOKENS]) +AT_DATA([define.sps], [dnl +DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE. +DEBUG EXPAND. +!t1 a. !t1 b. -!t1 a b.], - [t1(a) +!t1 a b. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +t1(a) + t1(b) + t1(a) -note: unexpanded token "b"]) + +note: unexpanded token "b" +]) +AT_CLEANUP AT_SETUP([macro expansion with positional arguments]) AT_DATA([define.sps], [dnl @@ -70,8 +80,8 @@ DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE. DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE. DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE. -DEFINE !ce(!positional !charend('/')) ce (!1) !ENDDEFINE. -DEFINE !ce2(!positional !charend('(') +DEFINE !ce(!positional=!charend('/')) ce (!1) !ENDDEFINE. +DEFINE !ce2(!positional=!charend('(') /!positional !charend(')')) ce2 (!1, !2) !ENDDEFINE. @@ -171,7 +181,9 @@ e(a b) cmd(1 2 3 4) -cmd2(5 6, 7) +cmd2(5 6, ) + +note: unexpanded token "7" "Three !TOKENS(1) arguments." @@ -181,106 +193,310 @@ p(1, -2, -3) (1 -2 -3) ]) AT_CLEANUP -AT_SETUP([macro expansion with positional arguments - negative]) +AT_SETUP([macro call missing positional !TOKENS arguments]) +AT_KEYWORDS([TOKENS]) AT_DATA([define.sps], [dnl -DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE. -DEFINE !p(!positional !tokens(1) - /!positional !tokens(1) - /!positional !tokens(1)) +DEFINE !p(!positional !tokens(1) !default(x) + /!positional !tokens(1) !default(y) + /!positional !tokens(1) !default(z)) (!1, !2, !3) !ENDDEFINE. - -DEFINE !ce(!positional !charend('/')) ce(!1) !ENDDEFINE. - -DEFINE !enc1(!positional !enclose('{', '}')) enc1(!1) !ENDDEFINE. DEBUG EXPAND. -!title "Too few tokens for !TOKENS." +!p a b c. !p a b. !p a. !p. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +(a, b, c) -!title "Missing charend delimiter." -!ce a b c. +(a, b, z) -!title "Missing start delimiter." -!enc1 a b c. +(a, y, z) + +(x, y, z) +]) +AT_CLEANUP -!title "Missing end delimiter." -!enc1{a b c. +AT_SETUP([macro call incomplete positional !TOKENS arguments]) +AT_KEYWORDS([TOKENS]) +AT_DATA([define.sps], [dnl +DEFINE !p(!positional !tokens(2) !default(x) + /!positional !tokens(2) !default(y) + /!positional !tokens(2) !default(z)) +(!1, !2, !3) +!ENDDEFINE. +DEBUG EXPAND. +!p a1 a2 b1 b2 c1 c2. +!p a1 a2 b1 b2 c1. +!p a1 a2 b1 b2. +!p a1 a2 b1. +!p a1 a2. +!p a1. +!p. ]) AT_CHECK([pspp --testing-mode define.sps], [1], [dnl -"Too few tokens for !TOKENS." +(a1 a2, b1 b2, c1 c2) -define.sps:13.7: error: DEBUG EXPAND: Unexpected end of command reading -argument !3 to macro !p. +define.sps:8.18: error: DEBUG EXPAND: Reached end of command expecting 1 more +token in argument !3 to macro !p. + 8 | !p a1 a2 b1 b2 c1. + | ^ -note: unexpanded token "!p" +(a1 a2, b1 b2, c1) -note: unexpanded token "a" +(a1 a2, b1 b2, z) -note: unexpanded token "b" +define.sps:10.12: error: DEBUG EXPAND: Reached end of command expecting 1 more +token in argument !2 to macro !p. + 10 | !p a1 a2 b1. + | ^ -define.sps:14.5: error: DEBUG EXPAND: Unexpected end of command reading +(a1 a2, b1, z) + +(a1 a2, y, z) + +define.sps:12.6: error: DEBUG EXPAND: Reached end of command expecting 1 more +token in argument !1 to macro !p. + 12 | !p a1. + | ^ + +(a1, y, z) + +(x, y, z) +]) +AT_CLEANUP + +AT_SETUP([macro call empty positional !CHAREND arguments]) +AT_KEYWORDS([CHAREND]) +AT_DATA([define.sps], [dnl +DEFINE !p(!positional !charend(',') !default(x) + /!positional !charend(';') !default(y) + /!positional !charend(':') !default(z)) +(!1, !2, !3) +!ENDDEFINE. +DEBUG EXPAND. +!p a,b;c:. +!p a,b;:. +!p a,;c:. +!p a,;:. +!p,b;c:. +!p,b;:. +!p,;c:. +!p,;:. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +(a, b, c) + +(a, b, ) + +(a, , c) + +(a, , ) + +(, b, c) + +(, b, ) + +(, , c) + +(, , ) +]) +AT_CLEANUP + +AT_SETUP([macro call missing positional !CHAREND arguments]) +AT_DATA([define.sps], [dnl +DEFINE !p(!positional !charend(',') !default(x) + /!positional !charend(';') !default(y) + /!positional !charend(':') !default(z)) +(!1, !2, !3) +!ENDDEFINE. +DEBUG EXPAND. +!p a,b;c:. +!p a,b;. +!p a,;. +!p ,b;. +!p ,;. + +!p a,. +!p ,. + +!p. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +(a, b, c) + +(a, b, z) + +(a, , z) + +(, b, z) + +(, , z) + +(a, y, z) + +(, y, z) + +(x, y, z) +]) +AT_CLEANUP + +AT_SETUP([macro call incomplete positional !CHAREND arguments]) +AT_KEYWORDS([CHAREND]) +AT_DATA([define.sps], [dnl +DEFINE !p(!positional !charend(',') !default(x) + /!positional !charend(';') !default(y) + /!positional !charend(':') !default(z)) +(!1, !2, !3) +!ENDDEFINE. +DEBUG EXPAND. +!p a,b;c:. +!p a,b;c. +!p a,b;. +!p a,b. +!p a,. +!p a. +!p. +]) +AT_CHECK([pspp --testing-mode define.sps], [1], [dnl +(a, b, c) + +define.sps:8.9: error: DEBUG EXPAND: Reached end of command expecting ":" in +argument !3 to macro !p. + 8 | !p a,b;c. + | ^ + +(a, b, c) + +(a, b, z) + +define.sps:10.7: error: DEBUG EXPAND: Reached end of command expecting ";" in argument !2 to macro !p. + 10 | !p a,b. + | ^ -note: unexpanded token "!p" +(a, b, z) -note: unexpanded token "a" +(a, y, z) -define.sps:15.3: error: DEBUG EXPAND: Unexpected end of command reading +define.sps:12.5: error: DEBUG EXPAND: Reached end of command expecting "," in argument !1 to macro !p. + 12 | !p a. + | ^ + +(a, y, z) + +(x, y, z) +]) +AT_CLEANUP -note: unexpanded token "!p" +AT_SETUP([macro call missing positional !ENCLOSE arguments]) +AT_KEYWORDS([ENCLOSE]) +AT_DATA([define.sps], [dnl +DEFINE !p(!positional !enclose('(',')') !default(x) + /!positional !enclose('<','>') !default(y) + /!positional !enclose('{','}') !default(z)) +(!1, !2, !3) +!ENDDEFINE. +DEBUG EXPAND. +!p (a){c}. +!p (a). +!p (a). +!p. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +(a, b, c) -"Missing charend delimiter." +(a, b, z) -define.sps:18.10: error: DEBUG EXPAND: Unexpected end of command reading -argument !1 to macro !ce. +(a, y, z) -note: unexpanded token "!ce" +(x, y, z) +]) +AT_CLEANUP -note: unexpanded token "a" +AT_SETUP([macro call incomplete positional !ENCLOSE arguments]) +AT_KEYWORDS([ENCLOSE]) +AT_DATA([define.sps], [dnl +DEFINE !p(!positional !enclose('(',')') !default(x) + /!positional !enclose('<','>') !default(y) + /!positional !enclose('{','}') !default(z)) +(!1, !2, !3) +!ENDDEFINE. +DEBUG EXPAND. +!p (a){c}. +!p (a){c. +!p (a){. +!p (a). +!p (a){c. + | ^ -note: unexpanded token "c" +(a, b, c) -"Missing start delimiter." +define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "}" in +argument !3 to macro !p. + 9 | !p (a){. + | ^ -define.sps:21.7: error: DEBUG EXPAND: Found `a' while expecting `{' reading -argument !1 to macro !enc1. +(a, b, ) -note: unexpanded token "!enc1" +(a, b, z) -note: unexpanded token "a" +define.sps:11.9: error: DEBUG EXPAND: Reached end of command expecting ">" in +argument !2 to macro !p. + 11 | !p (a)" in +argument !2 to macro !p. + 12 | !p (a)<. + | ^ -"Missing end delimiter." +(a, , z) -define.sps:24.12: error: DEBUG EXPAND: Unexpected end of command reading -argument !1 to macro !enc1. +(a, y, z) -note: unexpanded token "!enc1" +define.sps:14.6: error: DEBUG EXPAND: Reached end of command expecting ")" in +argument !1 to macro !p. + 14 | !p (a. + | ^ -note: unexpanded token "{" +(a, y, z) -note: unexpanded token "a" +define.sps:15.5: error: DEBUG EXPAND: Reached end of command expecting ")" in +argument !1 to macro !p. + 15 | !p (. + | ^ -note: unexpanded token "b" +(, y, z) -note: unexpanded token "c" +(x, y, z) ]) AT_CLEANUP AT_SETUP([keyword macro argument name with ! prefix]) AT_DATA([define.sps], [dnl -DEFINE !macro(!x=!TOKENS(1). +DEFINE !macro(!x !TOKENS(1). ]) AT_CHECK([pspp -O format=csv define.sps], [1], [dnl -"define.sps:1.15-1.16: error: DEFINE: Syntax error at `!x': Keyword macro parameter must be named in definition without ""!"" prefix." +"define.sps:1.15-1.16: error: DEFINE: Keyword macro parameter must be named in definition without ""!"" prefix. + 1 | DEFINE !macro@{:@!x !TOKENS(1). + | ^~" ]) AT_CLEANUP @@ -289,93 +505,244 @@ AT_DATA([define.sps], [dnl DEFINE !macro(if=!TOKENS(1). ]) AT_CHECK([pspp -O format=csv define.sps], [1], [dnl -"define.sps:1.15-1.16: error: DEFINE: Syntax error at `if': Cannot use macro keyword ""if"" as an argument name." +"define.sps:1.15-1.16: error: DEFINE: Cannot use macro keyword ""if"" as an argument name. + 1 | DEFINE !macro@{:@if=!TOKENS(1). + | ^~" ]) AT_CLEANUP -PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) keyword argument], - [DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.], - [!k arg1=x. +AT_SETUP([macro expansion - one !TOKENS(1) keyword argument]) +AT_KEYWORDS([TOKENS]) +AT_DATA([define.sps], [dnl +DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE. +DEBUG EXPAND. +!k arg1=x. !k arg1=x y. -!k.], - [k(x) +!k. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl k(x) + +k(x) + note: unexpanded token "y" -k( )]) -PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) keyword argument - negative], - [DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.], - [!k arg1. -!k arg1=.], [dnl +k( ) +]) +AT_CLEANUP + +AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative]) +AT_KEYWORDS([TOKENS]) +AT_DATA([define.sps], [dnl +DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE. +DEBUG EXPAND. +!k arg1. +!k arg1=. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [1], [dnl define.sps:3.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading argument !arg1 to macro !k. -note: unexpanded token "!k" -note: unexpanded token "arg1" -define.sps:4.9: error: DEBUG EXPAND: Unexpected end of command reading argument -!arg1 to macro !k. -note: unexpanded token "!k" -note: unexpanded token "arg1" -note: unexpanded token "="], [1]) - -PSPP_CHECK_MACRO_EXPANSION([!CHAREND('/') keyword arguments], [dnl + 3 | !k arg1. + | ^ + +k( ) + +define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more +token in argument !arg1 to macro !k. + 4 | !k arg1=. + | ^ + +k( ) +]) +AT_CLEANUP + +AT_SETUP([macro expansion - !CHAREND keyword arguments]) +AT_KEYWORDS([CHAREND]) +AT_DATA([define.sps], [dnl DEFINE !k(arg1 = !CHAREND('/') /arg2 = !CHAREND('/')) k(!arg1, !arg2) -!ENDDEFINE.], - [!k arg1=x/ arg2=y/. +!ENDDEFINE. +DEBUG EXPAND. +!k arg1=x/ arg2=y/. !k arg1=x/. !k arg2=y/. -!k.], - [k(x, y) +!k. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +k(x, y) + k(x, ) + k(, y) -k(, )]) -PSPP_CHECK_MACRO_EXPANSION([!CHAREND('/') keyword arguments - negative], [dnl +k(, ) +]) +AT_CLEANUP + +AT_SETUP([macro expansion - !CHAREND keyword arguments - negative]) +AT_KEYWORDS([CHAREND]) +AT_DATA([define.sps], [dnl DEFINE !k(arg1 = !CHAREND('/') /arg2 = !CHAREND('/')) k(!arg1, !arg2) -!ENDDEFINE.], - [!k arg1. +!ENDDEFINE. +DEBUG EXPAND. +!k arg1. !k arg1=. !k arg1=x. -!k arg1=x/ arg2=y.], - [define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading +!k arg1=x/ arg2=y. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [1], [dnl +define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading +argument !arg1 to macro !k. + 6 | !k arg1. + | ^ + +k(, ) + +define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in argument !arg1 to macro !k. -note: unexpanded token "!k" -note: unexpanded token "arg1" -define.sps:7.9: error: DEBUG EXPAND: Unexpected end of command reading argument -!arg1 to macro !k. -note: unexpanded token "!k" -note: unexpanded token "arg1" -note: unexpanded token "=" -define.sps:8.10: error: DEBUG EXPAND: Unexpected end of command reading + 7 | !k arg1=. + | ^ + +k(, ) + +define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in argument !arg1 to macro !k. -note: unexpanded token "!k" -note: unexpanded token "arg1" -note: unexpanded token "=" -note: unexpanded token "x" -define.sps:9.18: error: DEBUG EXPAND: Unexpected end of command reading + 8 | !k arg1=x. + | ^ + +k(x, ) + +define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in argument !arg2 to macro !k. -note: unexpanded token "!k" -note: unexpanded token "arg1" -note: unexpanded token "=" + 9 | !k arg1=x/ arg2=y. + | ^ + +k(x, y) +]) +AT_CLEANUP + +AT_SETUP([macro expansion - !ENCLOSE keyword arguments]) +AT_KEYWORDS([ENCLOSE]) +AT_DATA([define.sps], [dnl +DEFINE !k(arg1 = !ENCLOSE('(',')') + /arg2 = !ENCLOSE('{','}')) +k(!arg1, !arg2) +!ENDDEFINE. +DEBUG EXPAND. +!k arg1=(x) arg2={y}. +!k arg1=(x). +!k arg2={y}. +!k. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +k(x, y) + +k(x, ) + +k(, y) + +k(, ) +]) +AT_CLEANUP + +AT_SETUP([macro expansion - !ENCLOSE keyword arguments - negative]) +AT_KEYWORDS([ENCLOSE]) +AT_DATA([define.sps], [dnl +DEFINE !k(arg1 = !ENCLOSE('(',')') + /arg2 = !ENCLOSE('{','}')) +k(!arg1, !arg2) +!ENDDEFINE. +DEBUG EXPAND. +!k arg1. +!k arg1=. +!k arg1=x. +!k arg1=(x. +!k arg1=(x) arg2. +!k arg1=(x) arg2=. +!k arg1=(x) arg2=y. +!k arg1=(x) arg2=(y. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [1], [dnl +define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading +argument !arg1 to macro !k. + 6 | !k arg1. + | ^ + +k(, ) + +define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading +argument !arg1 to macro !k. + 7 | !k arg1=. + | ^ + +k(, ) + +define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading +argument !arg1 to macro !k. + 8 | !k arg1=x. + | ^ + +k(, ) + note: unexpanded token "x" -note: unexpanded token "/" -note: unexpanded token "arg2" -note: unexpanded token "=" -note: unexpanded token "y"]) - -PSPP_CHECK_MACRO_EXPANSION([default keyword arguments], - [DEFINE !k(arg1 = !CMDEND !DEFAULT(a b c)) k(!arg1) !ENDDEFINE], - [!k arg1=x. -!k], - [k(x) -k(a b c)]) + +define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "@:}@" in +argument !arg1 to macro !k. + 9 | !k arg1=@{:@x. + | ^ + +k(x, ) + +define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading +argument !arg2 to macro !k. + 10 | !k arg1=(x) arg2. + | ^ + +k(x, ) + +define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading +argument !arg2 to macro !k. + 11 | !k arg1=(x) arg2=. + | ^ + +k(x, ) + +define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading +argument !arg2 to macro !k. + 12 | !k arg1=(x) arg2=y. + | ^ + +k(x, ) + +note: unexpanded token "y" + +define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading +argument !arg2 to macro !k. + 13 | !k arg1=(x) arg2=@{:@y. + | ^ + +k(x, ) + +note: unexpanded token "@{:@" + +note: unexpanded token "y" +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !BLANKS in the manual. -PSPP_CHECK_MACRO_EXPANSION([!BLANKS], - [DEFINE !b() +AT_SETUP([macro expansion - !BLANKS]) +AT_KEYWORDS([BLANKS]) +AT_DATA([define.sps], [dnl +DEFINE !b() !BLANKS(0). !QUOTE(!BLANKS(0)). !BLANKS(1). @@ -384,20 +751,28 @@ PSPP_CHECK_MACRO_EXPANSION([!BLANKS], !QUOTE(!BLANKS(2)). !BLANKS(5). !QUOTE(!BLANKS(5)). -!ENDDEFINE], - [!b.], - [. +!ENDDEFINE. +DEBUG EXPAND. +!b. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +. ''. . ' '. . ' '. . -' '.]) +' '. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !CONCAT in the manual. -PSPP_CHECK_MACRO_EXPANSION([!CONCAT], - [DEFINE !c() +AT_SETUP([macro expansion - !CONCAT]) +AT_KEYWORDS([CONCAT]) +AT_DATA([define.sps], [dnl +DEFINE !c() !CONCAT(x, y). !CONCAT('x', 'y'). !CONCAT(12, 34). @@ -406,92 +781,135 @@ PSPP_CHECK_MACRO_EXPANSION([!CONCAT], !CONCAT(x, 0, y). !CONCAT(0, x). !CONCAT(0, x, y). -!ENDDEFINE], - [!c.], - [xy. +!ENDDEFINE. +DEBUG EXPAND. +!c +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +xy. xy. 1234. 123. x0. x0y. 0 x. -0 xy.]) +0 xy. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !EVAL in the manual. -PSPP_CHECK_MACRO_EXPANSION([!EVAL], - [DEFINE !vars() a b c !ENDDEFINE. +AT_SETUP([macro expansion - !EVAL]) +AT_KEYWORDS([EVAL]) +AT_DATA([define.sps], [dnl +DEFINE !vars() a b c !ENDDEFINE. + DEFINE !e() !vars. !QUOTE(!vars). !EVAL(!vars). !QUOTE(!EVAL(!vars)). !ENDDEFINE + DEFINE !e2(!positional !enclose('(',')')) !1. !QUOTE(!1). !EVAL(!1). !QUOTE(!EVAL(!1)). -!ENDDEFINE], - [!e. -!e2(!vars)], - [a b c. +!ENDDEFINE. +DEBUG EXPAND. +!e. +!e2(!vars). +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +a b c. '!vars'. a b c. 'a b c'. + a b c. '!vars'. a b c. -'a b c'.]) +'a b c'. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !HEAD in the manual. -PSPP_CHECK_MACRO_EXPANSION([!HEAD], - [DEFINE !h() +AT_SETUP([macro expansion - !HEAD]) +AT_KEYWORDS([HEAD]) +AT_DATA([define.sps], [dnl +DEFINE !h() !HEAD('a b c'). !HEAD('a'). !HEAD(!NULL). !HEAD(''). -!ENDDEFINE], - [!h.], - [a. +!ENDDEFINE. +DEBUG EXPAND. +!h. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +a. a. . -.]) +. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !TAIL in the manual. -PSPP_CHECK_MACRO_EXPANSION([!TAIL], - [DEFINE !t() +AT_SETUP([macro expansion - !TAIL]) +AT_KEYWORDS([TAIL]) +AT_DATA([define.sps], [dnl +DEFINE !t() !TAIL('a b c'). !TAIL('a'). !TAIL(!NULL). !TAIL(''). -!ENDDEFINE], - [!t.], - [b c. +!ENDDEFINE. +DEBUG EXPAND. +!t. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +b c. +. . . -.]) +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !INDEX in the manual. -PSPP_CHECK_MACRO_EXPANSION([!INDEX], - [DEFINE !i() +AT_SETUP([macro expansion - !INDEX]) +AT_KEYWORDS([INDEX]) +AT_DATA([define.sps], [dnl +DEFINE !i() !INDEX(banana, an). !INDEX(banana, nan). !INDEX(banana, apple). !INDEX("banana", nan). !INDEX("banana", "nan"). !INDEX(!UNQUOTE("banana"), !UNQUOTE("nan")). -!ENDDEFINE], - [!i.], - [2. +!ENDDEFINE. +DEBUG EXPAND. +!i. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +2. 3. 0. 4. 0. -3.]) +3. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !LENGTH in the manual. -PSPP_CHECK_MACRO_EXPANSION([!LENGTH], - [DEFINE !l() +AT_SETUP([macro expansion - !LENGTH]) +AT_KEYWORDS([LENGTH]) +AT_DATA([define.sps], [dnl +DEFINE !l() !LENGTH(123). !LENGTH(123.00). !LENGTH( 123 ). @@ -505,11 +923,15 @@ PSPP_CHECK_MACRO_EXPANSION([!LENGTH], !ENDDEFINE. DEFINE !la(!positional !enclose('(',')')) !LENGTH(!1). -!ENDDEFINE.], - [!l. +!ENDDEFINE. +DEBUG EXPAND. +!l. !la(a b c). -!la().], - [3. +!la(). +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +3. 6. 3. 5. @@ -519,12 +941,84 @@ DEFINE !la(!positional !enclose('(',')')) 5. 6. 0. + 5. -0.]) + +0. +]) +AT_CLEANUP + +dnl Keep this test in sync with the examples for !NULL in the manual. +AT_SETUP([macro expansion - !NULL]) +AT_KEYWORDS([NULL]) +AT_DATA([define.sps], [dnl +DEFINE !n() +!NULL. +!QUOTE(!NULL). +!ENDDEFINE. +DEBUG EXPAND. +!n. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +. +''. +]) +AT_CLEANUP + +dnl Keep this test in sync with the examples for !QUOTE and !UNQUOTE in the manual. +AT_SETUP([macro expansion - !QUOTE and !UNQUOTE]) +AT_KEYWORDS([QUOTE UNQUOTE]) +AT_DATA([define.sps], [dnl +DEFINE !q(!POS !CMDEND) +!QUOTE(123.0). +!QUOTE( 123 ). +!QUOTE('a b c'). +!QUOTE("a b c"). +!QUOTE(!1). + +!UNQUOTE(123.0). +!UNQUOTE( 123 ). +!UNQUOTE('a b c'). +!UNQUOTE("a b c"). +!UNQUOTE(!1). + +!QUOTE(!UNQUOTE(123.0)). +!QUOTE(!UNQUOTE( 123 )). +!QUOTE(!UNQUOTE('a b c')). +!QUOTE(!UNQUOTE("a b c")). +!QUOTE(!UNQUOTE(!1)). +!ENDDEFINE. +DEBUG EXPAND. +!q a 'b' c. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +'123.0'. +'123'. +'a b c'. +"a b c". +'a ''b'' c'. + +123.0. +123. +a b c. +a b c. +a 'b' c. + +'123.0'. +'123'. +'a b c'. +'a b c'. +'a ''b'' c'. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !SUBSTR in the manual. -PSPP_CHECK_MACRO_EXPANSION([!SUBSTR], - [DEFINE !s() +AT_SETUP([macro expansion - !SUBSTR]) +AT_KEYWORDS([SUBSTR]) +AT_DATA([define.sps], [dnl +DEFINE !s() !SUBSTR(banana, 3). !SUBSTR(banana, 3, 3). !SUBSTR("banana", 1, 3). @@ -533,11 +1027,18 @@ PSPP_CHECK_MACRO_EXPANSION([!SUBSTR], !SUBSTR(banana, 3, 0). !SUBSTR(banana, 3, 10). !SUBSTR(banana, 10, 3). -!ENDDEFINE.], - [!s.], - [define.sps:1-10: At `"ba' in the expansion of `!s',dnl " +!ENDDEFINE. +DEBUG EXPAND. +!s. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [1], [dnl +define.sps:1-10: At `"ba' in the expansion of `!s',dnl " define.sps:12.1-12.2: error: DEBUG EXPAND: Unterminated string constant. + 12 | !s. + | ^~ + nana. nan. . @@ -545,39 +1046,57 @@ nana. ana. . nana. -.]) +. +]) +AT_CLEANUP dnl Keep this test in sync with the examples for !UPCASE in the manual. -PSPP_CHECK_MACRO_EXPANSION([!UPCASE], - [DEFINE !u() +AT_SETUP([macro expansion - !UPCASE]) +AT_KEYWORDS([UPCASE]) +AT_DATA([define.sps], [dnl +DEFINE !u() !UPCASE(freckle). !UPCASE('freckle'). !UPCASE('a b c'). !UPCASE('A B C'). -!ENDDEFINE.], - [!u.], - [FRECKLE. +!ENDDEFINE. +DEBUG EXPAND. +!u. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +FRECKLE. FRECKLE. A B C. -A B C.]) - +A B C. +]) +AT_CLEANUP dnl !* is implemented separately inside and outside function arguments dnl so this test makes sure to include both. -PSPP_CHECK_MACRO_EXPANSION([!*], [dnl +AT_SETUP([macro expansion - !*]) +AT_DATA([define.sps], [dnl DEFINE !m(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)) !*/ !LENGTH(!*)/ !SUBSTR(!*, 3)/ !QUOTE(!*). -!ENDDEFINE.], - [!m 123 b +!ENDDEFINE. +DEBUG EXPAND. +!m 123 b !m 2 3 !m '' 'b'. -], [123 b / 5 / 3 b / '123 b'. +]) +AT_CAPTURE_FILE([define.sps]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +123 b / 5 / 3 b / '123 b'. + 2 3 / 3 / 3 / '2 3'. -'' 'b' / 6 / 'b' / ''''' ''b'''.]) + +'' 'b' / 6 / 'b' / ''''' ''b'''. +]) +AT_CLEANUP AT_SETUP([macro maximum nesting level (MNEST)]) AT_KEYWORDS([MNEST]) @@ -639,9 +1158,13 @@ define.sps:1-3: inside the expansion of `!macro', define.sps:1-3: inside the expansion of `!macro', define.sps:1-3: inside the expansion of `!macro', define.sps:1-3: inside the expansion of `!macro', -define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.)" +define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.) + 4 | !macro. + | ^~~~~~" -define.sps:4.1-4.6: error: Syntax error at `!macro' (in expansion of `!macro'): expecting command name. +"define.sps:4.1-4.6: error: In syntax expanded from `!macro': Syntax error expecting command name. + 4 | !macro. + | ^~~~~~" ]) AT_CLEANUP @@ -910,12 +1433,16 @@ AT_CHECK([pspp --testing-mode define.sps], [1], [dnl define.sps:1-3: At `!x' in the expansion of `!for', define.sps:10.1-10.12: error: DEBUG EXPAND: Cannot use argument name or macro keyword as !DO variable. + 10 | !for x=1 y=5. + | ^~~~~~~~~~~~ !DO 1 = 1 !TO 5 !var !DOEND. define.sps:5-7: At `!noexpand' in the expansion of `!for2', define.sps:11.1-11.13: error: DEBUG EXPAND: Cannot use argument name or macro keyword as !DO variable. + 11 | !for2 x=1 y=5. + | ^~~~~~~~~~~~~ !DO !noexpand = 1 !TO 5 !var !DOEND. ]) @@ -960,6 +1487,8 @@ In the expansion of `!DO', define.sps:3-5: inside the expansion of `!for', define.sps:14.1-14.8: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum number of iterations 3. (Use SET MITERATE to change the limit.) + 14 | !for 1 5. + | ^~~~~~~~ 1 2 3 4. @@ -967,6 +1496,8 @@ In the expansion of `!DO', define.sps:7-9: inside the expansion of `!forby', define.sps:15.1-15.12: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum number of iterations 3. (Use SET MITERATE to change the limit.) + 15 | !forby 1 5 1. + | ^~~~~~~~~~~~ 1 2 3 4. @@ -986,6 +1517,8 @@ In the expansion of `!DO', define.sps:7-9: inside the expansion of `!forby', define.sps:23.1-23.13: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum number of iterations 3. (Use SET MITERATE to change the limit.) + 23 | !forby 5 1 -1. + | ^~~~~~~~~~~~~ 5 4 3 2. @@ -1063,15 +1596,19 @@ DEBUG EXPAND. AT_CHECK([pspp --testing-mode define.sps], [1], [dnl In the expansion of `!DO', define.sps:1-3: inside the expansion of `!for', -define.sps:7.1-7.11: error: DEBUG EXPAND: !DO loop over list exceeded maximum +define.sps:7.1-7.10: error: DEBUG EXPAND: !DO loop over list exceeded maximum number of iterations 2. (Use SET MITERATE to change the limit.) + 7 | !for a b c. + | ^~~~~~~~~~ ( (a) (b) ). In the expansion of `!DO', define.sps:1-3: inside the expansion of `!for', -define.sps:8.1-8.24: error: DEBUG EXPAND: !DO loop over list exceeded maximum +define.sps:8.1-8.23: error: DEBUG EXPAND: !DO loop over list exceeded maximum number of iterations 2. (Use SET MITERATE to change the limit.) + 8 | !for 'foo bar baz quux'. + | ^~~~~~~~~~~~~~~~~~~~~~~ ( (foo) (bar) ). @@ -1146,15 +1683,21 @@ DEBUG EXPAND. ]) AT_CHECK([pspp --testing-mode define.sps -O format=csv], [1], [dnl "define.sps:1-3: At `!x' in the expansion of `!macro', -define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable." +define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable. + 10 | !macro x=1. + | ^~~~~~~~~~" !LET 1 = 1 "define.sps:5-7: At `!do' in the expansion of `!macro2', -define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable." +define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable. + 11 | !macro2. + | ^~~~~~~" "define.sps:5-7: At `=' in the expansion of `!macro2', -define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO." +define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO. + 11 | !macro2. + | ^~~~~~~" !LET !do = x ]) @@ -1194,7 +1737,8 @@ $command prefix !paste foo bar suffix. SHOW $command. EOF cat >expout <')) !a(!tmp) !ENDDEFINE. +DEBUG EXPAND. +!b{y}. +!c{y}. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +[[x y z]] -define.sps:17.12-17.22: error: N OF CASES: Syntax error at `!minus !one': -Expected positive integer for N OF CASES. +[[ < y > ]] ]) AT_CLEANUP \ No newline at end of file