diff options
Diffstat (limited to 'contrib/bmake/unit-tests/cond-func.mk')
-rw-r--r-- | contrib/bmake/unit-tests/cond-func.mk | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/contrib/bmake/unit-tests/cond-func.mk b/contrib/bmake/unit-tests/cond-func.mk index 4ff43b72ef88..aabd31b4db46 100644 --- a/contrib/bmake/unit-tests/cond-func.mk +++ b/contrib/bmake/unit-tests/cond-func.mk @@ -1,12 +1,12 @@ -# $NetBSD: cond-func.mk,v 1.9 2020/11/15 14:07:53 rillig Exp $ +# $NetBSD: cond-func.mk,v 1.14 2023/11/19 21:47:52 rillig Exp $ # # Tests for those parts of the functions in .if conditions that are common # among several functions. # -# The below test uses the function defined(...) since it has no side-effects, -# the other functions (except empty(...)) would work equally well. The -# function empty is special because it uses a different parsing algorithm for -# its argument. +# The below test uses the 'defined' function since it has no side-effects. +# The other functions would work equally well, except for 'empty', which +# parses its argument differently from the other functions. +# DEF= defined ${:UA B}= variable name with spaces @@ -33,11 +33,12 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces .endif # The argument of a function must not directly contain whitespace. +# expect+1: Missing closing parenthesis for defined() .if !defined(A B) . error .endif -# If necessary, the whitespace can be generated by a variable expression. +# If necessary, the whitespace can be generated by an expression. .if !defined(${:UA B}) . error .endif @@ -48,9 +49,11 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces # # It's not entirely clear why these characters are forbidden. # The most plausible reason seems to be typo detection. +# expect+1: Missing closing parenthesis for defined() .if !defined(A&B) . error .endif +# expect+1: Missing closing parenthesis for defined() .if !defined(A|B) . error .endif @@ -74,7 +77,7 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces # There may be spaces around the operators and parentheses, and even # inside the parentheses. The spaces inside the parentheses are not -# allowed for the empty() function (see cond-func-empty.mk), therefore +# allowed for the 'empty' function (see cond-func-empty.mk), therefore # they are typically omitted for the other functions as well. .if ! defined ( DEF ) . error @@ -91,22 +94,26 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces .if defined() . error .else +# expect+1: The empty variable is never defined. . info The empty variable is never defined. .endif -# The plain word 'defined' is interpreted as '!empty(defined)'. +# The plain word 'defined' is interpreted as 'defined(defined)', see +# CondParser_ComparisonOrLeaf. # That variable is not defined (yet). .if defined . error .else -. info A plain function name is parsed as !empty(...). +# expect+1: A plain function name is parsed as defined(...). +. info A plain function name is parsed as defined(...). .endif -# If a variable named 'defined' is actually defined and not empty, the plain -# symbol 'defined' evaluates to true. -defined= non-empty +# If a variable named 'defined' is actually defined, the bare word 'defined' +# is interpreted as 'defined(defined)', and the condition evaluates to true. +defined= # defined but empty .if defined -. info A plain function name is parsed as !empty(...). +# expect+1: A plain function name is parsed as defined(...). +. info A plain function name is parsed as defined(...). .else . error .endif @@ -116,22 +123,21 @@ defined= non-empty .if defined-var . error .else +# expect+1: Symbols may start with a function name. . info Symbols may start with a function name. .endif -defined-var= non-empty +defined-var= # defined but empty .if defined-var +# expect+1: Symbols may start with a function name. . info Symbols may start with a function name. .else . error .endif -# Missing closing parenthesis when parsing the function argument. +# expect+1: Missing closing parenthesis for defined() .if defined( . error .else . error .endif - -all: - @:; |