X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fcontrol%2Fdefine.at;h=fb66b01378429a2984e717d945d1b5e07ab18513;hb=492887218950ce96ac096de8327a52e13af2373d;hp=3c940c151380149e252bb4a7af7c17884f90b6f2;hpb=92635c65e5e265dc8114805af8974715539d90d2;p=pspp diff --git a/tests/language/control/define.at b/tests/language/control/define.at index 3c940c1513..fb66b01378 100644 --- a/tests/language/control/define.at +++ b/tests/language/control/define.at @@ -41,6 +41,18 @@ m(n, o). ]) AT_CLEANUP +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 @@ -228,6 +240,8 @@ AT_CHECK([pspp --testing-mode define.sps], [1], [dnl 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. + | ^ (a1 a2, b1 b2, c1) @@ -235,6 +249,8 @@ token in argument !3 to macro !p. 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. + | ^ (a1 a2, b1, z) @@ -242,6 +258,8 @@ token in argument !2 to macro !p. 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) @@ -346,6 +364,8 @@ AT_CHECK([pspp --testing-mode define.sps], [1], [dnl 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) @@ -353,6 +373,8 @@ argument !3 to macro !p. define.sps:10.7: error: DEBUG EXPAND: Reached end of command expecting ";" in argument !2 to macro !p. + 10 | !p a,b. + | ^ (a, b, z) @@ -360,6 +382,8 @@ argument !2 to macro !p. define.sps:12.5: error: DEBUG EXPAND: Reached end of command expecting "," in argument !1 to macro !p. + 12 | !p a. + | ^ (a, y, z) @@ -417,11 +441,15 @@ AT_CHECK([pspp --testing-mode define.sps], [1], [dnl define.sps:8.12: error: DEBUG EXPAND: Reached end of command expecting "}" in argument !3 to macro !p. + 8 | !p (a){c. + | ^ (a, b, c) define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "}" in argument !3 to macro !p. + 9 | !p (a){. + | ^ (a, b, ) @@ -429,11 +457,15 @@ argument !3 to macro !p. 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)<. + | ^ (a, , z) @@ -441,11 +473,15 @@ argument !2 to macro !p. define.sps:14.6: error: DEBUG EXPAND: Reached end of command expecting ")" in argument !1 to macro !p. + 14 | !p (a. + | ^ (a, y, z) define.sps:15.5: error: DEBUG EXPAND: Reached end of command expecting ")" in argument !1 to macro !p. + 15 | !p (. + | ^ (, y, z) @@ -458,7 +494,9 @@ AT_DATA([define.sps], [dnl 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 @@ -467,7 +505,9 @@ 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 @@ -504,11 +544,15 @@ 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. + 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( ) ]) @@ -556,21 +600,29 @@ 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. + 7 | !k arg1=. + | ^ k(, ) define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in argument !arg1 to macro !k. + 8 | !k arg1=x. + | ^ k(x, ) define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in argument !arg2 to macro !k. + 9 | !k arg1=x/ arg2=y. + | ^ k(x, y) ]) @@ -622,16 +674,22 @@ 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(, ) @@ -639,21 +697,29 @@ note: unexpanded token "x" 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, ) @@ -661,6 +727,8 @@ 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, ) @@ -880,6 +948,72 @@ AT_CHECK([pspp --testing-mode define.sps], [0], [dnl ]) 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. AT_SETUP([macro expansion - !SUBSTR]) AT_KEYWORDS([SUBSTR]) @@ -902,6 +1036,8 @@ 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. @@ -1022,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 @@ -1293,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. ]) @@ -1343,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. @@ -1350,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. @@ -1369,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. @@ -1448,6 +1598,8 @@ In the expansion of `!DO', define.sps:1-3: inside the expansion of `!for', 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) ). @@ -1455,6 +1607,8 @@ In the expansion of `!DO', define.sps:1-3: inside the expansion of `!for', 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) ). @@ -1529,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 ]) @@ -1577,7 +1737,8 @@ $command prefix !paste foo bar suffix. SHOW $command. EOF cat >expout <