diff options
Diffstat (limited to 'contrib/bmake/unit-tests/cond-cmp-string.mk')
-rw-r--r-- | contrib/bmake/unit-tests/cond-cmp-string.mk | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/contrib/bmake/unit-tests/cond-cmp-string.mk b/contrib/bmake/unit-tests/cond-cmp-string.mk index 305a41099b98..7b13ebf2212b 100644 --- a/contrib/bmake/unit-tests/cond-cmp-string.mk +++ b/contrib/bmake/unit-tests/cond-cmp-string.mk @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-string.mk,v 1.15 2021/12/11 09:53:53 rillig Exp $ +# $NetBSD: cond-cmp-string.mk,v 1.18 2023/11/19 21:47:52 rillig Exp $ # # Tests for string comparisons in .if conditions. @@ -15,15 +15,16 @@ # The left-hand side of the comparison must be enclosed in quotes. # This one is not enclosed in quotes and thus generates an error message. +# expect+1: Malformed conditional (str != str) .if str != str . error .endif -# The left-hand side of the comparison requires that any variable expression +# The left-hand side of the comparison requires that any expression # is defined. # # The variable named "" is never defined, nevertheless it can be used as a -# starting point for variable expressions. Applying the :U modifier to such +# starting point for expressions. Applying the :U modifier to such # an undefined expression turns it into a defined expression. # # See ApplyModifier_Defined and DEF_DEFINED. @@ -39,6 +40,7 @@ # It is not possible to concatenate two string literals to form a single # string. In C, Python and the shell this is possible, but not in make. +# expect+1: Malformed conditional ("string" != "str""ing") .if "string" != "str""ing" . error .else @@ -46,6 +48,7 @@ .endif # There is no = operator for strings. +# expect+1: Malformed conditional (!("value" = "value")) .if !("value" = "value") . error .else @@ -53,19 +56,20 @@ .endif # There is no === operator for strings either. +# expect+1: Malformed conditional (!("value" === "value")) .if !("value" === "value") . error .else . error .endif -# A variable expression can be enclosed in double quotes. +# An expression can be enclosed in double quotes. .if ${:Uword} != "${:Uword}" . error .endif # Between 2003-01-01 (maybe even earlier) and 2020-10-30, adding one of the -# characters " \t!=><" directly after a variable expression resulted in a +# characters " \t!=><" directly after an expression resulted in a # "Malformed conditional", even though the string was well-formed. .if ${:Uword } != "${:Uword} " . error @@ -85,12 +89,12 @@ . error .endif -# Adding another variable expression to the string literal works though. +# Adding another expression to the string literal works though. .if ${:Uword} != "${:Uwo}${:Urd}" . error .endif -# Adding a space at the beginning of the quoted variable expression works +# Adding a space at the beginning of the quoted expression works # though. .if ${:U word } != " ${:Uword} " . error @@ -110,6 +114,7 @@ .endif # Strings cannot be compared relationally, only for equality. +# expect+1: Comparison with '<' requires both operands 'string' and 'string' to be numeric .if "string" < "string" . error .else @@ -117,6 +122,7 @@ .endif # Strings cannot be compared relationally, only for equality. +# expect+1: Comparison with '<=' requires both operands 'string' and 'string' to be numeric .if "string" <= "string" . error .else @@ -124,6 +130,7 @@ .endif # Strings cannot be compared relationally, only for equality. +# expect+1: Comparison with '>' requires both operands 'string' and 'string' to be numeric .if "string" > "string" . error .else @@ -131,8 +138,17 @@ .endif # Strings cannot be compared relationally, only for equality. +# expect+1: Comparison with '>=' requires both operands 'string' and 'string' to be numeric .if "string" >= "string" . error .else . error .endif + +# Two variables with different values compare unequal. +VAR1= value1 +VAR2= value2 +.if ${VAR1} != ${VAR2} +.else +. error +.endif |