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): extend test for modifier pa...
details: https://anonhg.NetBSD.org/src/rev/17de05f9a9de
branches: trunk
changeset: 958181:17de05f9a9de
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Dec 28 00:19:41 2020 +0000
description:
make(1): extend test for modifier parts in ':=' assignments
diffstat:
usr.bin/make/unit-tests/var-op-expand.mk | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diffs (49 lines):
diff -r cd8a57e7a96f -r 17de05f9a9de usr.bin/make/unit-tests/var-op-expand.mk
--- a/usr.bin/make/unit-tests/var-op-expand.mk Mon Dec 28 00:14:18 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-expand.mk Mon Dec 28 00:19:41 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.9 2020/12/27 23:25:33 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.10 2020/12/28 00:19:41 rillig Exp $
#
# Tests for the := variable assignment operator, which expands its
# right-hand side.
@@ -118,22 +118,32 @@
# In variable assignments using the ':=' operator, there may be expressions
# containing variable modifiers, and these modifiers may refer to other
-# variables.
+# variables. These referred-to variables are expanded at the time of
+# assignment. The undefined variables are kept as-is and are later expanded
+# when evaluating the condition.
#
# 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:\$\$\$\$"
+.undef REF.undef
+VAR:= ${:Uword undef:@word@${REF.${word}}@}, direct: ${REF.word} ${REF.undef}
+REF.word= word.after
+REF.undef= undef.after
+.if ${VAR} != "1:2:\$ 4:\$\$ undef.after, direct: 1:\$ 2:\$\$ 4:\$\$\$\$ undef.after"
. error
.endif
-
# Just for comparison, the previous example using the assignment operator '='
-# instead of ':='.
+# instead of ':='. The right-hand side of the assignment is not evaluated at
+# the time of assignment but only later, when ${VAR} appears in the condition.
+#
+# At that point, both REF.word and REF.undef are defined.
REF.word= 1:$$ 2:$$$$ 4:$$$$$$$$
-VAR= ${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
-.if ${VAR} != "1:\$ 2:\$\$ 4:\$\$\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.undef REF.undef
+VAR= ${:Uword undef:@word@${REF.${word}}@}, direct: ${REF.word} ${REF.undef}
+REF.word= word.after
+REF.undef= undef.after
+.if ${VAR} != "word.after undef.after, direct: word.after undef.after"
. error
.endif
Home |
Main Index |
Thread Index |
Old Index