Module Name:    src
Committed By:   rillig
Date:           Tue Aug 25 21:58:08 UTC 2020

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

Log Message:
make(1): add test for the :D modifier


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-defined.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.2 src/usr.bin/make/unit-tests/varmod-defined.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-defined.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varmod-defined.mk	Tue Aug 25 21:58:08 2020
@@ -1,9 +1,28 @@
-# $NetBSD: varmod-defined.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-defined.mk,v 1.3 2020/08/25 21:58:08 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.
 
-# TODO: Implementation
+DEF=	defined
+.undef UNDEF
+
+# Since DEF is defined, the value of the expression is "value", not
+# "defined".
+#
+.if ${DEF:Dvalue} != "value"
+.error
+.endif
+
+# Since UNDEF is not defined, the "value" is ignored.  Instead of leaving the
+# expression undefined, it is set to "", exactly to allow the expression to
+# be used in .if conditions.  In this place, other undefined expressions
+# would generate an error message.
+# XXX: Ideally the error message would be "undefined variable", but as of
+# 2020-08-25 it is "Malformed conditional".
+#
+.if ${UNDEF:Dvalue} != ""
+.error
+.endif
 
 all:
 	@:;

Reply via email to