aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/cond-func.mk
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/unit-tests/cond-func.mk')
-rw-r--r--contrib/bmake/unit-tests/cond-func.mk40
1 files changed, 27 insertions, 13 deletions
diff --git a/contrib/bmake/unit-tests/cond-func.mk b/contrib/bmake/unit-tests/cond-func.mk
index 959367f5c6ab..50b3f83cd4cb 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.11 2022/01/07 19:30:17 rillig Exp $
+# $NetBSD: cond-func.mk,v 1.19 2025/06/28 22:39:28 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 ")" after argument "A" 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 ")" after argument "A" for "defined"
.if !defined(A&B)
. error
.endif
+# expect+1: Missing ")" after argument "A" for "defined"
.if !defined(A|B)
. error
.endif
@@ -74,24 +77,24 @@ ${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
.endif
-# The following condition is interpreted as defined(A) && defined(B).
-# In lack of a function call expression, each kind of .if directive has a
+# Before cond.c 1.366 from 2024-07-06, the following condition was
+# interpreted as defined(A) && defined(B). Each kind of .if directive has a
# default function that is called when a bare word is parsed. For the plain
-# .if directive, this function is defined(); see "struct If ifs" in cond.c.
+# .if directive, this function is 'defined'; see "struct If ifs" in cond.c.
+# expect+1: Unknown operator "&"
.if A&B
. error
.endif
+# The empty variable is never defined.
.if defined()
. error
-.else
-. info The empty variable is never defined.
.endif
# The plain word 'defined' is interpreted as 'defined(defined)', see
@@ -100,6 +103,7 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces
.if defined
. error
.else
+# expect+1: A plain function name is parsed as defined(...).
. info A plain function name is parsed as defined(...).
.endif
@@ -107,6 +111,7 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces
# is interpreted as 'defined(defined)', and the condition evaluates to true.
defined= # defined but empty
.if defined
+# expect+1: A plain function name is parsed as defined(...).
. info A plain function name is parsed as defined(...).
.else
. error
@@ -117,19 +122,28 @@ defined= # defined but 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= # 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 ")" after argument "" for "defined"
.if defined(
. error
.else
. error
.endif
+
+# expect+1: Missing ")" after argument "${:UVARNAME}.param" for "defined"
+.if defined(${:UVARNAME}.param extra)
+. error
+.else
+. error
+.endif