Module Name: src
Committed By: rillig
Date: Sun Dec 27 21:19:13 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk
Log Message:
make(1): add more tests for ':=' assignments
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.5 src/usr.bin/make/unit-tests/var-op-expand.mk:1.6
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.5 Sun Dec 27 20:45:52 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk Sun Dec 27 21:19:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.5 2020/12/27 20:45:52 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.6 2020/12/27 21:19:13 rillig Exp $
#
# Tests for the := variable assignment operator, which expands its
# right-hand side.
@@ -86,6 +86,36 @@ UNDEF= Uwas undefined
.endif
+# In variable assignments using the ':=' operator, undefined variables are
+# preserved, no matter how indirectly they are referenced.
+.undef REF3
+REF2= <${REF3}>
+REF= ${REF2}
+VAR:= ${REF}
+REF3= too late
+.if ${VAR} != "<too late>"
+. error
+.endif
+
+
+# In variable assignments using the ':=' operator, '$$' are preserved, no
+# matter how indirectly they are referenced.
+REF2= REF2:$$ $$$$
+REF= REF:$$ $$$$ ${REF2}
+VAR:= VAR:$$ $$$$ ${REF}
+.if ${VAR} != "VAR:\$ \$\$ REF:\$ \$\$ REF2:\$ \$\$"
+. error
+.endif
+
+
+# In variable assignments using the ':=' operator, '$$' are preserved in the
+# expressions of the top level, but not in expressions that are nested.
+VAR:= top:$$ ${:Unest1\:\$\$} ${:Unest2${:U\:\$\$}}
+.if ${VAR} != "top:\$ nest1:\$ nest2:\$"
+. error
+.endif
+
+
# XXX: edge case: When a variable name refers to an undefined variable, the
# behavior differs between the '=' and the ':=' assignment operators.
# This bug exists since var.c 1.42 from 2000-05-11.