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/584859cdf3a4
branches:  trunk
changeset: 976800:584859cdf3a4
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 becd3154da20 -r 584859cdf3a4 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