Module Name: src Committed By: rillig Date: Mon Dec 28 00:19:42 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: var-op-expand.mk Log Message: make(1): extend test for modifier parts in ':=' assignments To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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.9 src/usr.bin/make/unit-tests/var-op-expand.mk:1.10 --- src/usr.bin/make/unit-tests/var-op-expand.mk:1.9 Sun Dec 27 23:25:33 2020 +++ src/usr.bin/make/unit-tests/var-op-expand.mk Mon Dec 28 00:19:41 2020 @@ -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 @@ VAR:= top:$$ ${:Unest1\:\$\$} ${:Unest2 # 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