Module Name:    src
Committed By:   rillig
Date:           Thu Jan 27 20:15:14 UTC 2022

Modified Files:
        src/usr.bin/make/unit-tests: directive-for-escape.exp
            directive-for-escape.mk

Log Message:
tests/make: add more edge cases for expansion of .for loop body


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
    src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.14 -r1.15 \
    src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.16
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15	Thu Jan 27 11:26:44 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jan 27 20:15:14 2022
@@ -125,6 +125,15 @@ For: loop body:
 # ${:U${:U\$\$}}
 For: end for 1
 For: loop body:
+# ${:U${.TARGET}}
+For: loop body:
+# ${:U${.TARGET}}
+For: loop body:
+# ${:U$${.TARGET\}}
+For: loop body:
+# ${:U$${.TARGET\}}
+For: end for 1
+For: loop body:
 # ${:U(((}
 For: loop body:
 # ${:U{{{}

Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.14 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.15
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.14	Thu Jan 27 11:26:44 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Thu Jan 27 20:15:14 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.14 2022/01/27 11:26:44 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.15 2022/01/27 20:15:14 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -65,7 +65,7 @@ ${:U\\}=	backslash
 # FIXME: There was no expression '$\' in the original text of the previous
 # line, that's a surprise in the parser.
 # The modifier ':U' unescapes the '\$' to a simple '$'.
-# expect+4: ${UNDEF:U\$
+# expect+4: ${UNDEF:U\backslash$
 VALUES=		$${UNDEF:U\$$\$$ {{}} end}
 # XXX: Where in the code does the '\$\$' get converted into a single '\$'?
 .for i in ${VALUES}
@@ -178,6 +178,20 @@ ${closing-brace}=	<closing-brace>	# alte
 # $i
 .endfor
 
+# The expression '${.TARGET}' must be preserved as it is one of the 7 built-in
+# target-local variables.  See for.c 1.45 from 2009-01-14.
+.for i in ${.TARGET} $${.TARGET} $$${.TARGET} $$$${.TARGET}
+# $i
+.endfor
+# expect: # ${:U${.TARGET}}
+# XXX: Why does '$' result in the same text as '$$'?
+# expect: # ${:U${.TARGET}}
+# XXX: Why does the '$$' before the '${.TARGET}' lead to an escaped '}'?
+# expect: # ${:U$${.TARGET\}}
+# XXX: Why does '$' result in the same text as '$$'?
+# XXX: Why does the '$$' before the '${.TARGET}' lead to an escaped '}'?
+# expect: # ${:U$${.TARGET\}}
+
 .for i in ((( {{{ ))) }}}
 # $i
 .endfor

Reply via email to