!LET
[pspp] / tests / language / control / define.at
index 30fd080ba0454b178b65bfb307cfbbd1eb077d95..0571303da1b8a6f049f9a63c692328419f9ecb68 100644 (file)
@@ -384,12 +384,20 @@ PSPP_CHECK_MACRO_EXPANSION([!CONCAT],
 !CONCAT('x', 'y').
 !CONCAT(12, 34).
 !CONCAT(!NULL, 123).
+!CONCAT(x, 0).
+!CONCAT(x, 0, y).
+!CONCAT(0, x).
+!CONCAT(0, x, y).
 !ENDDEFINE],
   [!c.],
   [xy.
 xy.
 1234.
-123.])
+123.
+x0.
+x0y.
+0 x.
+0 xy.])
 
 dnl Keep this test in sync with the examples for !EVAL in the manual.
 PSPP_CHECK_MACRO_EXPANSION([!EVAL],
@@ -666,9 +674,14 @@ DEFINE !test_unary(!positional !tokens(1))
 !if $3 !1 !then true !else false !ifend.
 !ENDDEFINE.
 
-* This is ((not A) and B) or C.
+* These are:
+  ((not A) and B) or C
+  not (A and B) or C
+  not A and (B or C)
 DEFINE !test_prec(!pos !tokens(1)/!pos !tokens(1)/!pos !tokens(1))
 !if $3 !1 $1 !2 $2 !3 !then true !else false !ifend
+!if $3 (!1 $1 !2) $2 !3 !then true !else false !ifend
+!if $3 !1 $1 (!2 $2 !3) !then true !else false !ifend
 !ENDDEFINE.
 
 DEBUG EXPAND.
@@ -695,16 +708,51 @@ true.
 
 false.
 
-false
-true
-true
-true
+false true false
+true true true
+true true true
+true true true
 
-false
-true
-false
-true
+false true false
+true true false
+false false false
+true true false
 ])
 done
 AT_CLEANUP
 
+AT_SETUP([macro !LET])
+AT_KEYWORDS([let])
+AT_DATA([define.sps], [dnl
+DEFINE !macro(!POS !CMDEND)
+!LET !v1 = !CONCAT('x',!1,'y')
+!LET !v2 = !QUOTE(!v1)
+!LET !v3 = (!LENGTH(!1) = 1)
+!LET !v4 = (!SUBSTR(!1, 3) = !NULL)
+v1=!v1.
+v2=!v2.
+v3=!v3.
+v4=!v4.
+!ENDDEFINE.
+DEBUG EXPAND.
+!macro 0.
+!macro.
+!macro xyzzy.
+])
+AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
+v1 = x0y.
+v2 = 'x0y'.
+v3 = 1.
+v4 = 1.
+
+v1 = xy.
+v2 = 'xy'.
+v3 = 0.
+v4 = 1.
+
+v1 = xxyzzyy.
+v2 = 'xxyzzyy'.
+v3 = 0.
+v4 = 0.
+])
+AT_CLEANUP
\ No newline at end of file