dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
+dnl GNU nGeneral Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
"x "" y".
])
AT_CLEANUP
-\f
+
PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) positional argument],
[DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.],
[!t1 a.
t1(b)
t1(a)
note: unexpanded token "b"])
-\f
+
AT_SETUP([macro expansion with positional arguments])
AT_DATA([define.sps], [dnl
DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
DEFINE !p(!positional !tokens(1)
/!positional !tokens(1)
/!positional !tokens(1))
-p(!1, !2, !3)
+p(!1, !2, !3)(!*)
!ENDDEFINE.
DEBUG EXPAND.
"Three !TOKENS(1) arguments."
-p(a, b, c)
+p(a, b, c) (a b c)
-p(1, -2, -3)
+p(1, -2, -3) (1 -2 -3)
])
AT_CLEANUP
-\f
+
AT_SETUP([macro expansion with positional arguments - negative])
AT_DATA([define.sps], [dnl
DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
1234.
123.])
+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.
+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.
+'!vars'.
+a b c.
+'a b c'.
+a b c.
+'!vars'.
+a b c.
+'a b c'.])
+
dnl Keep this test in sync with the examples for !HEAD in the manual.
PSPP_CHECK_MACRO_EXPANSION([!HEAD],
[DEFINE !h()
!SUBSTR(banana, 3).
!SUBSTR(banana, 3, 3).
!SUBSTR("banana", 3).
+!SUBSTR(!UNQUOTE("banana"), 3).
!SUBSTR("banana", 3, 3).
!SUBSTR(banana, 3, 0).
!SUBSTR(banana, 3, 10).
!SUBSTR(banana, 10, 3).
!ENDDEFINE.],
[!s.],
- [nana.
+ [error
+nana.
nan.
-anana". dnl"
-
+anana.
+nana.
ana.
.
nana.
.])
+dnl Keep this test in sync with the examples for !UPCASE in the manual.
+PSPP_CHECK_MACRO_EXPANSION([!UPCASE],
+ [DEFINE !u()
+!UPCASE(freckle).
+!UPCASE('freckle').
+!UPCASE('a b c').
+!UPCASE('A B C').
+!ENDDEFINE.],
+ [!u.],
+ [FRECKLE.
+FRECKLE.
+A B C.
+A B C.])
+
+
+dnl !* is implemented separately inside and outside function arguments
+dnl so this test makes sure to include both.
+PSPP_CHECK_MACRO_EXPANSION([!*], [dnl
+DEFINE !m(!POSITIONAL !TOKENS(1)
+ /!POSITIONAL !TOKENS(1))
+!*/
+!LENGTH(!*)/
+!SUBSTR(!*, 3)/
+!QUOTE(!*).
+!ENDDEFINE.],
+ [!m 123 b
+!m 2 3
+!m '' 'b'.
+], [123 b / 5 / 3 b / '123 b'.
+2 3 / 3 / 3 / '2 3'.
+'' 'b' / 6 / 'b' / ''''' ''b'''.])
+
+AT_SETUP([macro maximum nesting level (MNEST)])
+AT_KEYWORDS([MNEST])
+AT_DATA([define.sps], [dnl
+DEFINE !macro()
+!macro
+!ENDDEFINE.
+!macro.
+])
+AT_CHECK([pspp define.sps], [1], [dnl
+maximum nesting level exceeded
+define.sps.1: error: Syntax error at `!macro': expecting command name.
+])
+AT_CLEANUP
\ No newline at end of file