Module Name:    src
Committed By:   rillig
Date:           Sat Sep 12 07:04:51 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: varmod-defined.mk varmod-undefined.mk

Log Message:
make(1): add tests for combining the :D and :U variable modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-defined.mk \
    src/usr.bin/make/unit-tests/varmod-undefined.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-defined.mk
diff -u src/usr.bin/make/unit-tests/varmod-defined.mk:1.4 src/usr.bin/make/unit-tests/varmod-defined.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-defined.mk:1.4	Thu Sep  3 18:52:36 2020
+++ src/usr.bin/make/unit-tests/varmod-defined.mk	Sat Sep 12 07:04:51 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-defined.mk,v 1.4 2020/09/03 18:52:36 rillig Exp $
+# $NetBSD: varmod-defined.mk,v 1.5 2020/09/12 07:04:51 rillig Exp $
 #
 # Tests for the :D variable modifier, which returns the given string
 # if the variable is defined.  It is closely related to the :U modifier.
@@ -60,6 +60,21 @@ DEF=	defined
 .  error
 .endif
 
+# The :D modifier is often used in combination with the :U modifier.
+# It does not matter in which order the :D and :U modifiers appear.
+.if ${UNDEF:Dyes:Uno} != no
+.  error
+.endif
+.if ${UNDEF:Uno:Dyes} != no
+.  error
+.endif
+.if ${DEF:Dyes:Uno} != yes
+.  error
+.endif
+.if ${DEF:Uno:Dyes} != yes
+.  error
+.endif
+
 # TODO: Add more tests for parsing the plain text part, to cover each branch
 # of ApplyModifier_Defined.
 
Index: src/usr.bin/make/unit-tests/varmod-undefined.mk
diff -u src/usr.bin/make/unit-tests/varmod-undefined.mk:1.4 src/usr.bin/make/unit-tests/varmod-undefined.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-undefined.mk:1.4	Thu Sep  3 18:52:36 2020
+++ src/usr.bin/make/unit-tests/varmod-undefined.mk	Sat Sep 12 07:04:51 2020
@@ -1,20 +1,22 @@
-# $NetBSD: varmod-undefined.mk,v 1.4 2020/09/03 18:52:36 rillig Exp $
+# $NetBSD: varmod-undefined.mk,v 1.5 2020/09/12 07:04:51 rillig Exp $
 #
 # Tests for the :U variable modifier, which returns the given string
 # if the variable is undefined.
 #
-# The pattern ${:Uword} is heavily used when expanding .for loops.
+# See also:
+#	varmod-defined.mk
 
+# The pattern ${:Uword} is heavily used when expanding .for loops.
+#
 # This is how an expanded .for loop looks like.
 # .for word in one
 # .  if ${word} != one
-# .    error ${word}
-# .  endif
-# .endfor
-
 .if ${:Uone} != one
+# .    error ${word}
 .  error ${:Uone}
+# .  endif
 .endif
+# .endfor
 
 # The variable expressions in the text of the :U modifier may be arbitrarily
 # nested.

Reply via email to