X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fcontrol%2Fdefine.at;h=8ca40cbaba396e853b727753a8589c43fcf568e6;hb=bb7605897eddfc1a416aa5cb2b6a3de13ee624de;hp=876d650130185e96b368c5da985747b5d9d36120;hpb=72d12e896c52ce226c43dce80f683204e46e4f05;p=pspp diff --git a/tests/language/control/define.at b/tests/language/control/define.at index 876d650130..8ca40cbaba 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 @@ -505,9 +517,7 @@ 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" +k( ) define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more token in argument !arg1 to macro !k. @@ -559,9 +569,7 @@ 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. -note: unexpanded token "!k" - -note: unexpanded token "arg1" +k(, ) define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in argument !arg1 to macro !k. @@ -627,27 +635,17 @@ 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. -note: unexpanded token "!k" - -note: unexpanded token "arg1" +k(, ) define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading argument !arg1 to macro !k. -note: unexpanded token "!k" - -note: unexpanded token "arg1" - -note: unexpanded token "=" +k(, ) define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading argument !arg1 to macro !k. -note: unexpanded token "!k" - -note: unexpanded token "arg1" - -note: unexpanded token "=" +k(, ) note: unexpanded token "x" @@ -659,78 +657,24 @@ k(x, ) define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading argument !arg2 to macro !k. -note: unexpanded token "!k" - -note: unexpanded token "arg1" - -note: unexpanded token "=" - -note: unexpanded token "@{:@" - -note: unexpanded token "x" - -note: unexpanded token "@:}@" - -note: unexpanded token "arg2" +k(x, ) define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading argument !arg2 to macro !k. -note: unexpanded token "!k" - -note: unexpanded token "arg1" - -note: unexpanded token "=" - -note: unexpanded token "@{:@" - -note: unexpanded token "x" - -note: unexpanded token "@:}@" - -note: unexpanded token "arg2" - -note: unexpanded token "=" +k(x, ) define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading argument !arg2 to macro !k. -note: unexpanded token "!k" - -note: unexpanded token "arg1" - -note: unexpanded token "=" - -note: unexpanded token "@{:@" - -note: unexpanded token "x" - -note: unexpanded token "@:}@" - -note: unexpanded token "arg2" - -note: unexpanded token "=" +k(x, ) note: unexpanded token "y" define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading argument !arg2 to macro !k. -note: unexpanded token "!k" - -note: unexpanded token "arg1" - -note: unexpanded token "=" - -note: unexpanded token "@{:@" - -note: unexpanded token "x" - -note: unexpanded token "@:}@" - -note: unexpanded token "arg2" - -note: unexpanded token "=" +k(x, ) note: unexpanded token "@{:@" @@ -948,6 +892,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]) @@ -1701,10 +1711,26 @@ not a multiple of 2. ]) AT_CLEANUP +AT_SETUP([macro name overlaps with macro function name]) +dnl !len is short for macro function !LENGTH. PSPP used to +dnl reject the following with "`(' expected following !LENGTH". +dnl Now PSPP only consider macro functions when the name is +dnl followed by '('. +AT_DATA([define.sps], [dnl +DEFINE !len() 5 !ENDDEFINE. +DEFINE !x() !eval(!len) !ENDDEFINE. +DEBUG EXPAND. +!x +]) +AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl +5 +]) +AT_CLEANUP + AT_SETUP([generic macro function syntax errors]) AT_DATA([define.sps], [dnl -DEFINE !a() !SUBSTR !ENDDEFINE. -DEFINE !b() !SUBSTR x !ENDDEFINE. + + DEFINE !c() !SUBSTR(1x) !ENDDEFINE. DEFINE !d() !SUBSTR(1 !ENDDEFINE. DEFINE !narg_blanks() !BLANKS() !ENDDEFINE. @@ -1721,8 +1747,8 @@ DEFINE !narg_unquote() !UNQUOTE() !ENDDEFINE. DEFINE !narg_upcase() !UPCASE() !ENDDEFINE. dnl ) DEBUG EXPAND. -!a. -!b. + + !c. !d. !narg_blanks. @@ -1739,16 +1765,6 @@ DEBUG EXPAND. !narg_upcase. ]) AT_CHECK([pspp --testing-mode define.sps], [1], [dnl -define.sps:1: In the expansion of `!a', -define.sps:18.1-18.2: error: DEBUG EXPAND: `@{:@' expected following !SUBSTR. - -!SUBSTR - -define.sps:2: At `x' in the expansion of `!b', -define.sps:19.1-19.2: error: DEBUG EXPAND: `@{:@' expected following !SUBSTR. - -!SUBSTR x - define.sps:3: At `x' in the expansion of `!c', define.sps:20.1-20.2: error: DEBUG EXPAND: `,' or `@:}@' expected in call to macro function !SUBSTR.