MNEST
[pspp] / tests / language / control / define.at
index fce0e3f832ee2172f28a3a7f5fd54e77f42c9c58..acafa4b4ea94bd9b53655971eb46b2b7df458017 100644 (file)
@@ -9,7 +9,7 @@ dnl
 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/>.
@@ -53,7 +53,7 @@ m(n, o).
 "x "" y".
 ])
 AT_CLEANUP
-\f
+
 PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) positional argument],
   [DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.],
   [!t1 a.
@@ -63,7 +63,7 @@ PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) positional argument],
 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.
@@ -87,7 +87,7 @@ cmd2(!1, !2)
 DEFINE !p(!positional !tokens(1)
          /!positional !tokens(1)
         /!positional !tokens(1))
-p(!1, !2, !3)
+p(!1, !2, !3)(!*)
 !ENDDEFINE.
 
 DEBUG EXPAND.
@@ -175,12 +175,12 @@ cmd2(5 6, 7)
 
 "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.
@@ -391,6 +391,32 @@ xy.
 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()
@@ -476,16 +502,18 @@ PSPP_CHECK_MACRO_EXPANSION([!SUBSTR],
 !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.
@@ -505,3 +533,34 @@ 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