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 more tests for ':=' ass...



details:   https://anonhg.NetBSD.org/src/rev/d6f3be766e79
branches:  trunk
changeset: 958175:d6f3be766e79
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 27 21:19:13 2020 +0000

description:
make(1): add more tests for ':=' assignments

diffstat:

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

diffs (46 lines):

diff -r b73cde8139c9 -r d6f3be766e79 usr.bin/make/unit-tests/var-op-expand.mk
--- a/usr.bin/make/unit-tests/var-op-expand.mk  Sun Dec 27 21:13:17 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-expand.mk  Sun Dec 27 21:19:13 2020 +0000
@@ -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 @@
 .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.



Home | Main Index | Thread Index | Old Index