Module Name:    src
Committed By:   rillig
Date:           Sun Dec 27 23:25:33 UTC 2020

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

Log Message:
make(1): add test for modifier parts in ':=' assignments


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-op-expand.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-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.8 src/usr.bin/make/unit-tests/var-op-expand.mk:1.9
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.8	Sun Dec 27 22:29:37 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Sun Dec 27 23:25:33 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.8 2020/12/27 22:29:37 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.9 2020/12/27 23:25:33 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -116,6 +116,28 @@ VAR:=		top:$$ ${:Unest1\:\$\$} ${:Unest2
 .endif
 
 
+# In variable assignments using the ':=' operator, there may be expressions
+# containing variable modifiers, and these modifiers may refer to other
+# variables.
+#
+# Contrary to the assignment operator '=', the assignment operator ':='
+# consumes the '$' from modifier parts.
+REF.word=	1:$$ 2:$$$$ 4:$$$$$$$$
+VAR:=		${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
+.if ${VAR} != "1:2:\$ 4:\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.  error
+.endif
+
+
+# Just for comparison, the previous example using the assignment operator '='
+# instead of ':='.
+REF.word=	1:$$ 2:$$$$ 4:$$$$$$$$
+VAR=		${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
+.if ${VAR} != "1:\$ 2:\$\$ 4:\$\$\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.  error
+.endif
+
+
 # Between var.c 1.42 from 2000-05-11 and before parse.c 1.520 from 2020-12-27,
 # if the variable name in a ':=' assignment referred to an undefined variable,
 # there were actually 2 assignments to different variables:

Reply via email to