X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fcontrol%2Fdefine.at;h=fa87f9a1de9f1c9859938f309b48cd4f1a3d7692;hb=5dd9df91d08bb0283bde1b82266a29f6e5e17bb3;hp=fa2670f9e6c367e67dace6389514e1c5ba709077;hpb=b707aef4702e0998353de081458b7720f67a1b72;p=pspp diff --git a/tests/language/control/define.at b/tests/language/control/define.at index fa2670f9e6..fa87f9a1de 100644 --- a/tests/language/control/define.at +++ b/tests/language/control/define.at @@ -275,6 +275,24 @@ note: unexpanded token "c" ]) AT_CLEANUP +AT_SETUP([keyword macro argument name with ! prefix]) +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." +]) +AT_CLEANUP + +AT_SETUP([reserved macro keyword argument name]) +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." +]) +AT_CLEANUP + PSPP_CHECK_MACRO_EXPANSION([one !TOKENS(1) keyword argument], [DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.], [!k arg1=x. @@ -819,6 +837,96 @@ AT_CHECK([pspp --testing-mode define.sps], [0], [dnl ]) AT_CLEANUP +AT_SETUP([macro !DO invalid variable names]) +AT_KEYWORDS([index do]) +AT_DATA([define.sps], [dnl +DEFINE !for(x=!TOKENS(1) / y=!TOKENS(1)) +!DO !x = !x !TO !y !var !DOEND. +!ENDDEFINE. + +DEFINE !for2(x=!TOKENS(1) / y=!TOKENS(1)) +!DO !noexpand = !x !TO !y !var !DOEND. +!ENDDEFINE. + +DEBUG EXPAND. +!for x=1 y=5. +!for2 x=1 y=5. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +cannot use argument name or macro keyword as !DO variable +cannot use argument name or macro keyword as !DO variable +!DO 1 = 1 !TO 5 !var !DOEND. + +!DO !noexpand = 1 !TO 5 !var !DOEND. +]) +AT_CLEANUP + +AT_SETUP([macro indexed !DO reaches MITERATE]) +AT_KEYWORDS([index do]) +AT_DATA([define.sps], [dnl +DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE. + +DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1)) +!DO !var = !1 !TO !2 !var !DOEND. +!ENDDEFINE. + +DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1)) +!DO !var = !1 !TO !2 !BY !3 !var !DOEND. +!ENDDEFINE. + +SET MITERATE=3. +DEBUG EXPAND. +!title "increasing". +!for 1 5. +!forby 1 5 1. +!forby 1 5 2. +!forby 1 5 2.5. +!forby 1 5 -1. + +!title "decreasing". +!for 5 1. +!forby 5 1 1. +!forby 5 1 -1. +!forby 5 1 -2. +!forby 5 1 -3. + +!title "non-integer". +!for 1.5 3.5. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +exceeded maximum number of iterations 3 +exceeded maximum number of iterations 3 +exceeded maximum number of iterations 3 +"increasing". + +1 2 3 4. + +1 2 3 4. + +1 3 5. + +1 3.5. + +. + +"decreasing". + +. + +. + +5 4 3 2. + +5 3 1. + +5 2. + +"non-integer". + +1.5 2.5 3.5. +]) +AT_CLEANUP + AT_SETUP([!BREAK with macro indexed !DO]) AT_KEYWORDS([index do break]) AT_DATA([define.sps], [dnl @@ -867,6 +975,30 @@ AT_CHECK([pspp --testing-mode define.sps], [0], [dnl ]) AT_CLEANUP +AT_SETUP([macro list !DO reaches MITERATE]) +AT_KEYWORDS([index do]) +AT_DATA([define.sps], [dnl +DEFINE !for(!POS !CMDEND) +(!DO !i !IN (!1) (!i) !DOEND). +!ENDDEFINE. + +SET MITERATE=2. +DEBUG EXPAND. +!for a b c. +!for 'foo bar baz quux'. +!for. +]) +AT_CHECK([pspp --testing-mode define.sps], [0], [dnl +exceeded maximum number of iterations 2 +exceeded maximum number of iterations 2 +( (a) (b) ). + +( (foo) (bar) ). + +( ). +]) +AT_CLEANUP + AT_SETUP([!BREAK with macro list !DO]) AT_KEYWORDS([index break do]) AT_DATA([define.sps], [dnl @@ -897,3 +1029,87 @@ AT_CHECK([pspp --testing-mode define.sps], [0], [dnl ( ). ]) AT_CLEANUP + +AT_SETUP([macro !LET]) +AT_DATA([define.sps], [dnl +DEFINE !macro(!pos !enclose('(',')')) +!LET !x=!1 +!LET !y=!QUOTE(!1) +!LET !z=(!y="abc") +!y !z +!ENDDEFINE. + +DEBUG EXPAND. +!macro(1+2). +!macro(abc). +]) +AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl +1 + 2 0 + +abc 1 +]) +AT_CLEANUP + +AT_SETUP([macro !LET invalid variable names]) +AT_DATA([define.sps], [dnl +DEFINE !macro(x=!tokens(1)) +!LET !x=!x +!ENDDEFINE. + +DEFINE !macro2() +!LET !do=x +!ENDDEFINE. + +DEBUG EXPAND. +!macro 1. +!macro2. +]) +AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl +cannot use argument name or macro keyword as !LET variable +cannot use argument name or macro keyword as !LET variable +expected macro variable name following !DO +!LET = + +!LET !do = x +]) +AT_CLEANUP + +AT_SETUP([BEGIN DATA inside a macro]) +AT_DATA([define.sps], [dnl +DEFINE !macro() +DATA LIST NOTABLE /x 1. +BEGIN DATA +1 +2 +3 +END DATA. +LIST. +!ENDDEFINE. + +!macro +]) +AT_CHECK([pspp define.sps -O format=csv], [0], [dnl +Table: Data List +x +1 +2 +3 +]) +AT_CLEANUP + +AT_SETUP([TITLE and SUBTITLE with macros]) +AT_KEYWORDS([macro]) +for command in TITLE SUBTITLE; do + cat >title.sps <expout <