Module Name:    src
Committed By:   rillig
Date:           Sun Oct  4 10:16:10 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: var-op-append.mk

Log Message:
make(1): add basic tests for the += assignment operator


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-append.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/var-op-append.mk
diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.2 src/usr.bin/make/unit-tests/var-op-append.mk:1.3
--- src/usr.bin/make/unit-tests/var-op-append.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/var-op-append.mk	Sun Oct  4 10:16:09 2020
@@ -1,9 +1,36 @@
-# $NetBSD: var-op-append.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: var-op-append.mk,v 1.3 2020/10/04 10:16:09 rillig Exp $
 #
 # Tests for the += variable assignment operator, which appends to a variable,
 # creating it if necessary.
 
-# TODO: Implementation
+# Appending to an undefined variable is possible.
+# The variable is created, and no extra space is added before the value.
+VAR+=	one
+.if ${VAR} != "one"
+.  error
+.endif
+
+# Appending to an existing variable adds a single space and the value.
+VAR+=	two
+.if ${VAR} != "one two"
+.  error
+.endif
+
+# Appending an empty string nevertheless adds a single space.
+VAR+=	# empty
+.if ${VAR} != "one two "
+.  error
+.endif
+
+# Variable names may contain '+', and this character is also part of the
+# '+=' assignment operator.  As far as possible, the '+' is interpreted as
+# part of the assignment operator.
+#
+# See Parse_DoVar
+C++=value
+.if ${C+} != "value" || defined(C++)
+.  error
+.endif
 
 all:
 	@:;

Reply via email to