Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add basic tests for the += ...



details:   https://anonhg.NetBSD.org/src/rev/818c4208dfdf
branches:  trunk
changeset: 955576:818c4208dfdf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 04 10:16:09 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/var-op-append.mk |  31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 485c3cfed97f -r 818c4208dfdf usr.bin/make/unit-tests/var-op-append.mk
--- a/usr.bin/make/unit-tests/var-op-append.mk  Sun Oct 04 09:42:48 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-append.mk  Sun Oct 04 10:16:09 2020 +0000
@@ -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:
        @:;



Home | Main Index | Thread Index | Old Index