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.
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.
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"
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 "@{:@"
])
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])
])
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.
DEFINE !narg_upcase() !UPCASE() !ENDDEFINE.
dnl )
DEBUG EXPAND.
-!a.
-!b.
+
+
!c.
!d.
!narg_blanks.
!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.