Module Name:    src
Committed By:   rillig
Date:           Sat Jul  6 10:14:35 UTC 2024

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

Log Message:
tests/make: clean up tests

Prefer "expect+X" directives to be above the code generating them,
instead of "expect-X" directives below the code.

In varmod-edge.mk, separate the tests, as the common loop does not pull
its weight.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/deptgt.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for-errors.exp
cvs rdiff -u -r1.12 -r1.13 \
    src/usr.bin/make/unit-tests/directive-for-errors.mk
cvs rdiff -u -r1.28 -r1.29 \
    src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.26 -r1.27 \
    src/usr.bin/make/unit-tests/directive-for-escape.mk \
    src/usr.bin/make/unit-tests/directive-for.mk
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-edge.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/deptgt.exp
diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.16 src/usr.bin/make/unit-tests/deptgt.exp:1.17
--- src/usr.bin/make/unit-tests/deptgt.exp:1.16	Fri Jul  5 20:01:52 2024
+++ src/usr.bin/make/unit-tests/deptgt.exp	Sat Jul  6 10:14:35 2024
@@ -8,6 +8,7 @@ ParseDependency(: empty-source)
 Parsing line 39: 	: command for empty targets list
 Parsing line 40: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
+make: "deptgt.mk" line 45: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z"
 make: "deptgt.mk" line 49: while parsing "${:U:Z}:": Unknown modifier "Z"
 make: "deptgt.mk" line 52: warning: Extra target 'ordinary' ignored
 make: "deptgt.mk" line 55: warning: Extra target (ordinary) ignored

Index: src/usr.bin/make/unit-tests/deptgt.mk
diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.19 src/usr.bin/make/unit-tests/deptgt.mk:1.20
--- src/usr.bin/make/unit-tests/deptgt.mk:1.19	Fri Jul  5 20:01:52 2024
+++ src/usr.bin/make/unit-tests/deptgt.mk	Sat Jul  6 10:14:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.19 2024/07/05 20:01:52 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.20 2024/07/06 10:14:35 rillig Exp $
 #
 # Tests for special targets like .BEGIN or .SUFFIXES in dependency
 # declarations.
@@ -39,14 +39,14 @@ ${:U}: empty-source
 	: command for empty targets list
 .MAKEFLAGS: -d0
 
-# Just to show that a malformed expression is only expanded once in
-# ParseDependencyTargetWord.  The only way to produce an expression that
-# is well-formed on the first expansion and ill-formed on the second
-# expansion would be to use the variable modifier '::=' to modify the
-# targets.  This in turn would be such an extreme and unreliable edge case
-# that nobody uses it.
+# In a dependency declaration, the whole line is expanded before interpreting
+# the line.
+# expect+1: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z"
+${:U:Z}:
+# After expanding the line as a whole, each target is parsed but not
+# evaluated, separately, in ParseDependencyTargetWord.
 # expect+1: while parsing "${:U:Z}:": Unknown modifier "Z"
-$$$$$$$${:U:Z}:
+$${:U:Z}:
 
 # expect+1: warning: Extra target 'ordinary' ignored
 .END ordinary:
@@ -56,6 +56,3 @@ $$$$$$$${:U:Z}:
 
 # expect+1: warning: Special and mundane targets don't mix. Mundane ones ignored
 ordinary .PATH:
-
-all:
-	@:;

Index: src/usr.bin/make/unit-tests/directive-for-errors.exp
diff -u src/usr.bin/make/unit-tests/directive-for-errors.exp:1.7 src/usr.bin/make/unit-tests/directive-for-errors.exp:1.8
--- src/usr.bin/make/unit-tests/directive-for-errors.exp:1.7	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/directive-for-errors.exp	Sat Jul  6 10:14:35 2024
@@ -1,17 +1,17 @@
 make: "directive-for-errors.mk" line 9: Unknown directive "fori"
-make: "directive-for-errors.mk" line 10: warning: <>
-make: "directive-for-errors.mk" line 11: for-less endfor
+make: "directive-for-errors.mk" line 11: warning: <>
+make: "directive-for-errors.mk" line 13: for-less endfor
 make: "directive-for-errors.mk" line 25: Unknown directive "for"
-make: "directive-for-errors.mk" line 26: warning: <>
-make: "directive-for-errors.mk" line 27: for-less endfor
+make: "directive-for-errors.mk" line 27: warning: <>
+make: "directive-for-errors.mk" line 29: for-less endfor
 make: "directive-for-errors.mk" line 44: invalid character '$' in .for loop variable name
 make: "directive-for-errors.mk" line 52: no iteration variables in for
 make: "directive-for-errors.mk" line 64: Wrong number of words (5) in .for substitution list with 3 variables
 make: "directive-for-errors.mk" line 78: missing `in' in for
 make: "directive-for-errors.mk" line 89: while evaluating "${:U3:Z} 4" with value "3": Unknown modifier "Z"
-make: "directive-for-errors.mk" line 90: warning: Should not be reached.
-make: "directive-for-errors.mk" line 90: warning: Should not be reached.
-make: "directive-for-errors.mk" line 90: warning: Should not be reached.
+make: "directive-for-errors.mk" line 93: warning: Should not be reached.
+make: "directive-for-errors.mk" line 93: warning: Should not be reached.
+make: "directive-for-errors.mk" line 93: warning: Should not be reached.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-for-errors.mk
diff -u src/usr.bin/make/unit-tests/directive-for-errors.mk:1.12 src/usr.bin/make/unit-tests/directive-for-errors.mk:1.13
--- src/usr.bin/make/unit-tests/directive-for-errors.mk:1.12	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/directive-for-errors.mk	Sat Jul  6 10:14:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-errors.mk,v 1.12 2024/07/05 19:47:22 rillig Exp $
+# $NetBSD: directive-for-errors.mk,v 1.13 2024/07/06 10:14:35 rillig Exp $
 #
 # Tests for error handling in .for loops.
 
@@ -7,10 +7,10 @@
 # in a parse error.
 # expect+1: Unknown directive "fori"
 .fori in 1 2 3
+# expect+1: warning: <>
 .  warning <${i}>
+# expect+1: for-less endfor
 .endfor
-# expect-2: warning: <>
-# expect-2: for-less endfor
 
 
 # A slash is not whitespace, therefore this is not parsed as a .for loop.
@@ -23,10 +23,10 @@
 # name is parsed a bit differently.
 # expect+1: Unknown directive "for"
 .for/i in 1 2 3
+# expect+1: warning: <>
 .  warning <${i}>
+# expect+1: for-less endfor
 .endfor
-# expect-2: warning: <>
-# expect-2: for-less endfor
 
 
 # Before for.c 1.173 from 2023-05-08, the variable name could be an arbitrary
@@ -87,8 +87,8 @@ ${:U\\}=	backslash	# see whether the "va
 # the loop body is expanded as if no error had happened.
 # expect+1: while evaluating "${:U3:Z} 4" with value "3": Unknown modifier "Z"
 .for i in 1 2 ${:U3:Z} 4
+# expect+3: warning: Should not be reached.
+# expect+2: warning: Should not be reached.
+# expect+1: warning: Should not be reached.
 .  warning Should not be reached.
 .endfor
-# expect-2: warning: Should not be reached.
-# expect-3: warning: Should not be reached.
-# expect-4: warning: Should not be reached.

Index: src/usr.bin/make/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.28 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.29
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.28	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Sat Jul  6 10:14:35 2024
@@ -16,36 +16,121 @@ make: "directive-for-escape.mk" line 33:
 make: "directive-for-escape.mk" line 33: !"\\
 For: end for 1
 For: loop body with i = $:
+# expect: .  info ${:U\$}
+# expect+9: $
+# expect: .  info ${:U${V}}
+# expect+7: value
+# expect: .  info ${:U${V:=-with-modifier}}
+# expect+5: value-with-modifier
+# expect: .  info ${:U$(V)}
+# expect+3: value
+# expect: .  info ${:U$(V:=-with-modifier)}
+# expect+1: value-with-modifier
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 47: $
+make: "directive-for-escape.mk" line 57: $
 For: loop body with i = ${V}:
+# expect: .  info ${:U\$}
+# expect+9: $
+# expect: .  info ${:U${V}}
+# expect+7: value
+# expect: .  info ${:U${V:=-with-modifier}}
+# expect+5: value-with-modifier
+# expect: .  info ${:U$(V)}
+# expect+3: value
+# expect: .  info ${:U$(V:=-with-modifier)}
+# expect+1: value-with-modifier
 .  info ${:U${V}}
-make: "directive-for-escape.mk" line 47: value
+make: "directive-for-escape.mk" line 57: value
 For: loop body with i = ${V:=-with-modifier}:
+# expect: .  info ${:U\$}
+# expect+9: $
+# expect: .  info ${:U${V}}
+# expect+7: value
+# expect: .  info ${:U${V:=-with-modifier}}
+# expect+5: value-with-modifier
+# expect: .  info ${:U$(V)}
+# expect+3: value
+# expect: .  info ${:U$(V:=-with-modifier)}
+# expect+1: value-with-modifier
 .  info ${:U${V:=-with-modifier}}
-make: "directive-for-escape.mk" line 47: value-with-modifier
+make: "directive-for-escape.mk" line 57: value-with-modifier
 For: loop body with i = $(V):
+# expect: .  info ${:U\$}
+# expect+9: $
+# expect: .  info ${:U${V}}
+# expect+7: value
+# expect: .  info ${:U${V:=-with-modifier}}
+# expect+5: value-with-modifier
+# expect: .  info ${:U$(V)}
+# expect+3: value
+# expect: .  info ${:U$(V:=-with-modifier)}
+# expect+1: value-with-modifier
 .  info ${:U$(V)}
-make: "directive-for-escape.mk" line 47: value
+make: "directive-for-escape.mk" line 57: value
 For: loop body with i = $(V:=-with-modifier):
+# expect: .  info ${:U\$}
+# expect+9: $
+# expect: .  info ${:U${V}}
+# expect+7: value
+# expect: .  info ${:U${V:=-with-modifier}}
+# expect+5: value-with-modifier
+# expect: .  info ${:U$(V)}
+# expect+3: value
+# expect: .  info ${:U$(V:=-with-modifier)}
+# expect+1: value-with-modifier
 .  info ${:U$(V:=-with-modifier)}
-make: "directive-for-escape.mk" line 47: value-with-modifier
+make: "directive-for-escape.mk" line 57: value-with-modifier
 For: end for 1
 For: loop body with i = $:
+# expect: .  info ${:U\$}
+# expect+6: $
+# expect: .  info ${:U${V}}
+# expect+4: value
+# expect+3: value-with-modifier
+# expect+2: value
+# expect+1: value-with-modifier
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 62: $
+make: "directive-for-escape.mk" line 69: $
 For: loop body with i = ${V}:
+# expect: .  info ${:U\$}
+# expect+6: $
+# expect: .  info ${:U${V}}
+# expect+4: value
+# expect+3: value-with-modifier
+# expect+2: value
+# expect+1: value-with-modifier
 .  info ${:U${V}}
-make: "directive-for-escape.mk" line 62: value
+make: "directive-for-escape.mk" line 69: value
 For: loop body with i = ${V:=-with-modifier}:
+# expect: .  info ${:U\$}
+# expect+6: $
+# expect: .  info ${:U${V}}
+# expect+4: value
+# expect+3: value-with-modifier
+# expect+2: value
+# expect+1: value-with-modifier
 .  info ${:U${V:=-with-modifier}}
-make: "directive-for-escape.mk" line 62: value-with-modifier
+make: "directive-for-escape.mk" line 69: value-with-modifier
 For: loop body with i = $(V):
+# expect: .  info ${:U\$}
+# expect+6: $
+# expect: .  info ${:U${V}}
+# expect+4: value
+# expect+3: value-with-modifier
+# expect+2: value
+# expect+1: value-with-modifier
 .  info ${:U$(V)}
-make: "directive-for-escape.mk" line 62: value
+make: "directive-for-escape.mk" line 69: value
 For: loop body with i = $(V:=-with-modifier):
+# expect: .  info ${:U\$}
+# expect+6: $
+# expect: .  info ${:U${V}}
+# expect+4: value
+# expect+3: value-with-modifier
+# expect+2: value
+# expect+1: value-with-modifier
 .  info ${:U$(V:=-with-modifier)}
-make: "directive-for-escape.mk" line 62: value-with-modifier
+make: "directive-for-escape.mk" line 69: value-with-modifier
 For: end for 1
 For: loop body with i = ${UNDEF:U\$\$:
 # ${:U\${UNDEF\:U\\$\\$}
@@ -55,82 +140,105 @@ For: loop body with i = end}:
 # ${:Uend\}}
 For: end for 1
 For: loop body with i = ${UNDEF:U\$\$:
+# expect+3: ${UNDEF:U\backslash$
+# expect+2: {{}}
+# expect+1: end}
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 117: ${UNDEF:U\backslash$
+make: "directive-for-escape.mk" line 120: ${UNDEF:U\backslash$
 For: loop body with i = {{}}:
+# expect+3: ${UNDEF:U\backslash$
+# expect+2: {{}}
+# expect+1: end}
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 117: {{}}
+make: "directive-for-escape.mk" line 120: {{}}
 For: loop body with i = end}:
+# expect+3: ${UNDEF:U\backslash$
+# expect+2: {{}}
+# expect+1: end}
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 117: end}
+make: "directive-for-escape.mk" line 120: end}
 For: end for 1
 For: loop body with i = begin<${UNDEF:Ufallback:N{{{}}}}>end:
+# expect+1: begin<fallback>end
 .  info ${:Ubegin<${UNDEF:Ufallback:N{{{}}}}>end}
 make: "directive-for-escape.mk" line 138: begin<fallback>end
 For: end for 1
 For: loop body with i = $:
+# expect+1: $
 .  info ${:U\$}
 make: "directive-for-escape.mk" line 147: $
-make: "directive-for-escape.mk" line 156: invalid character ':' in .for loop variable name
+make: "directive-for-escape.mk" line 155: invalid character ':' in .for loop variable name
 For: end for 1
-make: "directive-for-escape.mk" line 166: invalid character '}' in .for loop variable name
+make: "directive-for-escape.mk" line 165: invalid character '}' in .for loop variable name
 For: end for 1
 For: end for 1
 For: loop body with i = inner:
+# expect+1: .        ${:Uinner}: inner
 .  info .        $$i: ${:Uinner}
+# expect+1: .      ${:Uinner}: inner
 .  info .      $${i}: ${:Uinner}
+# expect+1: .   ${:Uinner:M*}: inner
 .  info .   $${i:M*}: ${:Uinner:M*}
+# expect+1: .      $(:Uinner): inner
 .  info .      $$(i): $(:Uinner)
+# expect+1: .   $(:Uinner:M*): inner
 .  info .   $$(i:M*): $(:Uinner:M*)
+# expect+1: . ${i${:U}}: outer
 .  info . $${i$${:U}}: ${i${:U}}
+# expect+1: .    ${:Uinner\}}: inner}
 .  info .    $${i\}}: ${:Uinner\}}	# XXX: unclear why ForLoop_SubstVarLong needs this
+# expect+1: .     ${i2}: two
 .  info .     $${i2}: ${i2}
+# expect+1: .     ${i,}: comma
 .  info .     $${i,}: ${i,}
+# expect+1: .  adjacent: innerinnerinnerinner
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
 make: "directive-for-escape.mk" line 175: .        $i: inner
-make: "directive-for-escape.mk" line 176: .      ${i}: inner
-make: "directive-for-escape.mk" line 177: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 178: .      $(i): inner
-make: "directive-for-escape.mk" line 179: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 180: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 181: .    ${i\}}: inner}
-make: "directive-for-escape.mk" line 182: .     ${i2}: two
-make: "directive-for-escape.mk" line 183: .     ${i,}: comma
-make: "directive-for-escape.mk" line 184: .  adjacent: innerinnerinnerinner
-make: "directive-for-escape.mk" line 203: invalid character '$' in .for loop variable name
+make: "directive-for-escape.mk" line 177: .      ${i}: inner
+make: "directive-for-escape.mk" line 179: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 181: .      $(i): inner
+make: "directive-for-escape.mk" line 183: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 185: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 187: .    ${i\}}: inner}
+make: "directive-for-escape.mk" line 189: .     ${i2}: two
+make: "directive-for-escape.mk" line 191: .     ${i,}: comma
+make: "directive-for-escape.mk" line 193: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 202: invalid character '$' in .for loop variable name
 For: end for 1
-make: "directive-for-escape.mk" line 215: eight  and no cents.
+make: "directive-for-escape.mk" line 214: eight  and no cents.
 For: end for 1
-make: "directive-for-escape.mk" line 228: newline in .for value
-	in .for loop from directive-for-escape.mk:228 with i = "
+make: "directive-for-escape.mk" line 227: newline in .for value
+	in .for loop from directive-for-escape.mk:227 with i = "
 "
-make: "directive-for-escape.mk" line 228: newline in .for value
-	in .for loop from directive-for-escape.mk:228 with i = "
+make: "directive-for-escape.mk" line 227: newline in .for value
+	in .for loop from directive-for-escape.mk:227 with i = "
 "
 For: loop body with i = "
 ":
+# expect+1: short: " "
 .  info short: ${:U" "}
+# expect+1: long: " "
 .  info long: ${:U" "}
 make: "directive-for-escape.mk" line 229: short: " "
-make: "directive-for-escape.mk" line 230: long: " "
+make: "directive-for-escape.mk" line 231: long: " "
 For: end for 1
 For: loop body with i = "
 ":
-Parsing line 246: .for i in "${.newline}"
+Parsing line 244: .for i in "${.newline}"
 For: end for 1
-Parse_PushInput: .for loop in directive-for-escape.mk, line 246
-make: "directive-for-escape.mk" line 246: newline in .for value
-	in .for loop from directive-for-escape.mk:246 with i = "
+Parse_PushInput: .for loop in directive-for-escape.mk, line 244
+make: "directive-for-escape.mk" line 244: newline in .for value
+	in .for loop from directive-for-escape.mk:244 with i = "
 "
 For: loop body with i = "
 ":
 : ${:U" "}
 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk'
-Parsing line 247: : ${:U" "}
+Parsing line 245: : ${:U" "}
 ParseDependency(: " ")
-ParseEOF: returning to file directive-for-escape.mk, line 249
+ParseEOF: returning to file directive-for-escape.mk, line 247
 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk'
-Parsing line 249: .MAKEFLAGS: -d0
+Parsing line 247: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 For: end for 1
 For: loop body with i = #:

Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.26 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.27
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.26	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Sat Jul  6 10:14:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.26 2024/07/05 19:47:22 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.27 2024/07/06 10:14:35 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
@@ -44,30 +44,30 @@ ASCII.2020-12-31=	!"\\\#$$%&'()*+,-./0-9
 V=		value
 VALUES=		$$ $${V} $${V:=-with-modifier} $$(V) $$(V:=-with-modifier)
 .for i in ${VALUES}
-.  info $i
-.endfor
 # expect: .  info ${:U\$}
-# expect-3: $
+# expect+9: $
 # expect: .  info ${:U${V}}
-# expect-5: value
+# expect+7: value
 # expect: .  info ${:U${V:=-with-modifier}}
-# expect-7: value-with-modifier
+# expect+5: value-with-modifier
 # expect: .  info ${:U$(V)}
-# expect-9: value
+# expect+3: value
 # expect: .  info ${:U$(V:=-with-modifier)}
-# expect-11: value-with-modifier
+# expect+1: value-with-modifier
+.  info $i
+.endfor
 #
 # Providing the loop items directly has the same effect.
 .for i in $$ $${V} $${V:=-with-modifier} $$(V) $$(V:=-with-modifier)
-.  info $i
-.endfor
 # expect: .  info ${:U\$}
-# expect-3: $
+# expect+6: $
 # expect: .  info ${:U${V}}
-# expect-5: value
-# expect-6: value-with-modifier
-# expect-7: value
-# expect-8: value-with-modifier
+# expect+4: value
+# expect+3: value-with-modifier
+# expect+2: value
+# expect+1: value-with-modifier
+.  info $i
+.endfor
 
 # Try to cover the code for nested '{}' in ExprLen, without success.
 #
@@ -114,13 +114,12 @@ VALUES=		$${UNDEF:U\$$\$$ {{}} end}
 # To make the expression '$\' visible, define it to an actual word:
 ${:U\\}=	backslash
 .for i in ${VALUES}
+# expect+3: ${UNDEF:U\backslash$
+# expect+2: {{}}
+# expect+1: end}
 .  info $i
 .endfor
 #
-# expect-3: ${UNDEF:U\backslash$
-# expect-4: {{}}
-# expect-5: end}
-#
 # FIXME: There was no expression '$\' in the original text of the variable
 # 'VALUES', that's a surprise in the parser.
 
@@ -135,18 +134,18 @@ ${:U\\}=	backslash
 # Var_Parse do all the parsing work.
 VALUES=		begin<$${UNDEF:Ufallback:N{{{}}}}>end
 .for i in ${VALUES}
+# expect+1: begin<fallback>end
 .  info $i
 .endfor
-# expect-2: begin<fallback>end
 
 # A single trailing dollar doesn't happen in practice.
 # The dollar sign is correctly passed through to the body of the .for loop.
 # There, it is expanded by the .info directive, but even there a trailing
 # dollar sign is kept as-is.
 .for i in ${:U\$}
+# expect+1: $
 .  info ${i}
 .endfor
-# expect-2: $
 
 # Before for.c 1.173 from 2023-05-08, the name of the iteration variable
 # could contain colons, which affected expressions having this exact
@@ -172,27 +171,27 @@ i=		outer
 i2=		two
 i,=		comma
 .for i in inner
+# expect+1: .        $i: inner
 .  info .        $$i: $i
+# expect+1: .      ${i}: inner
 .  info .      $${i}: ${i}
+# expect+1: .   ${i:M*}: inner
 .  info .   $${i:M*}: ${i:M*}
+# expect+1: .      $(i): inner
 .  info .      $$(i): $(i)
+# expect+1: .   $(i:M*): inner
 .  info .   $$(i:M*): $(i:M*)
+# expect+1: . ${i${:U}}: outer
 .  info . $${i$${:U}}: ${i${:U}}
+# expect+1: .    ${i\}}: inner}
 .  info .    $${i\}}: ${i\}}	# XXX: unclear why ForLoop_SubstVarLong needs this
+# expect+1: .     ${i2}: two
 .  info .     $${i2}: ${i2}
+# expect+1: .     ${i,}: comma
 .  info .     $${i,}: ${i,}
+# expect+1: .  adjacent: innerinnerinnerinner
 .  info .  adjacent: $i${i}${i:M*}$i
 .endfor
-# expect-11: .        $i: inner
-# expect-11: .      ${i}: inner
-# expect-11: .   ${i:M*}: inner
-# expect-11: .      $(i): inner
-# expect-11: .   $(i:M*): inner
-# expect-11: . ${i${:U}}: outer
-# expect-11: .    ${i\}}: inner}
-# expect-11: .     ${i2}: two
-# expect-11: .     ${i,}: comma
-# expect-11: .  adjacent: innerinnerinnerinner
 
 # Before for.c 1.173 from 2023-05-08, the variable name could be a single '$'
 # since there was no check on valid variable names.  ForLoop_SubstVarShort
@@ -226,13 +225,12 @@ ${closing-brace}=	<closing-brace>	# alte
 # expect+2: newline in .for value
 # expect+1: newline in .for value
 .for i in "${.newline}"
+# expect+1: short: " "
 .  info short: $i
+# expect+1: long: " "
 .  info long: ${i}
 .endfor
-# expect-3: short: " "
-# expect-3: long: " "
-
-# No error since the newline character is not actually used.
+# No error since the newline character is not actually used in the body.
 .for i in "${.newline}"
 .endfor
 
Index: src/usr.bin/make/unit-tests/directive-for.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.26 src/usr.bin/make/unit-tests/directive-for.mk:1.27
--- src/usr.bin/make/unit-tests/directive-for.mk:1.26	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/directive-for.mk	Sat Jul  6 10:14:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.26 2024/07/05 19:47:22 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.27 2024/07/06 10:14:35 rillig Exp $
 #
 # Tests for the .for directive.
 #
@@ -132,31 +132,31 @@ EXPANSION${plus}=	value
 # variable values have been replaced with expressions of the form ${:U...},
 # which are not interpreted as code anymore.
 .for path in a:\ a:\file.txt d:\\ d:\\file.txt
+# expect+3: a:\ a:\file.txt
+# expect+2: d:\\
+# expect+1: d:\\file.txt
 .  info ${path}
 .endfor
-# expect-2: a:\ a:\file.txt
-# expect-3: d:\\
-# expect-4: d:\\file.txt
 
 
 # Ensure that braces and parentheses are properly escaped by the .for loop.
 # Each line must print the same word 3 times.
 # See ForLoop_SubstBody.
 .for v in ( [ { ) ] } (()) [[]] {{}} )( ][ }{
+# expect+12: ( ( (
+# expect+11: [ [ [
+# expect+10: { { {
+# expect+9: ) ) )
+# expect+8: ] ] ]
+# expect+7: } } }
+# expect+6: (()) (()) (())
+# expect+5: [[]] [[]] [[]]
+# expect+4: {{}} {{}} {{}}
+# expect+3: )( )( )(
+# expect+2: ][ ][ ][
+# expect+1: }{ }{ }{
 .  info $v ${v} $(v)
 .endfor
-# expect-02: ( ( (
-# expect-03: [ [ [
-# expect-04: { { {
-# expect-05: ) ) )
-# expect-06: ] ] ]
-# expect-07: } } }
-# expect-08: (()) (()) (())
-# expect-09: [[]] [[]] [[]]
-# expect-10: {{}} {{}} {{}}
-# expect-11: )( )( )(
-# expect-12: ][ ][ ][
-# expect-13: }{ }{ }{
 
 # Before 2023-05-09, the variable names could contain arbitrary characters,
 # except for whitespace, allowing for creative side effects, as usual for
@@ -208,11 +208,11 @@ INDIRECT=	${DIRECT}
 # usual.
 # expect+1: while evaluating "${:Uword2:Z}-after word3" with value "word2": Unknown modifier "Z"
 .for var in word1 before-${:Uword2:Z}-after word3
+# expect+3: XXX: Should not reach word1
+# expect+2: XXX: Should not reach before--after
+# expect+1: XXX: Should not reach word3
 .  info XXX: Should not reach ${var}
 .endfor
-# expect-2: XXX: Should not reach word1
-# expect-3: XXX: Should not reach before--after
-# expect-4: XXX: Should not reach word3
 
 
 # An empty list of variables to the left of the 'in' is a parse error.
@@ -315,6 +315,6 @@ INDIRECT=	${DIRECT}
 # Back then, the .newline variable didn't exist, therefore it was unlikely
 # that a newline ever occurred.
 .for var in a${.newline}b${.newline}c
+# expect+1: newline-item=(a)
 .  info newline-item=(${var})
 .endfor
-# expect-2: newline-item=(a)

Index: src/usr.bin/make/unit-tests/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.24 src/usr.bin/make/unit-tests/directive-for.exp:1.25
--- src/usr.bin/make/unit-tests/directive-for.exp:1.24	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/directive-for.exp	Sat Jul  6 10:14:35 2024
@@ -1,26 +1,26 @@
 make: "directive-for.mk" line 117: outer
-make: "directive-for.mk" line 135: a:\ a:\file.txt
-make: "directive-for.mk" line 135: d:\\
-make: "directive-for.mk" line 135: d:\\file.txt
-make: "directive-for.mk" line 146: ( ( (
-make: "directive-for.mk" line 146: [ [ [
-make: "directive-for.mk" line 146: { { {
-make: "directive-for.mk" line 146: ) ) )
-make: "directive-for.mk" line 146: ] ] ]
-make: "directive-for.mk" line 146: } } }
-make: "directive-for.mk" line 146: (()) (()) (())
-make: "directive-for.mk" line 146: [[]] [[]] [[]]
-make: "directive-for.mk" line 146: {{}} {{}} {{}}
-make: "directive-for.mk" line 146: )( )( )(
-make: "directive-for.mk" line 146: ][ ][ ][
-make: "directive-for.mk" line 146: }{ }{ }{
+make: "directive-for.mk" line 138: a:\ a:\file.txt
+make: "directive-for.mk" line 138: d:\\
+make: "directive-for.mk" line 138: d:\\file.txt
+make: "directive-for.mk" line 158: ( ( (
+make: "directive-for.mk" line 158: [ [ [
+make: "directive-for.mk" line 158: { { {
+make: "directive-for.mk" line 158: ) ) )
+make: "directive-for.mk" line 158: ] ] ]
+make: "directive-for.mk" line 158: } } }
+make: "directive-for.mk" line 158: (()) (()) (())
+make: "directive-for.mk" line 158: [[]] [[]] [[]]
+make: "directive-for.mk" line 158: {{}} {{}} {{}}
+make: "directive-for.mk" line 158: )( )( )(
+make: "directive-for.mk" line 158: ][ ][ ][
+make: "directive-for.mk" line 158: }{ }{ }{
 make: "directive-for.mk" line 166: invalid character ':' in .for loop variable name
 make: "directive-for.mk" line 173: invalid character '$' in .for loop variable name
 make: "directive-for.mk" line 185: invalid character '$' in .for loop variable name
 make: "directive-for.mk" line 210: while evaluating "${:Uword2:Z}-after word3" with value "word2": Unknown modifier "Z"
-make: "directive-for.mk" line 211: XXX: Should not reach word1
-make: "directive-for.mk" line 211: XXX: Should not reach before--after
-make: "directive-for.mk" line 211: XXX: Should not reach word3
+make: "directive-for.mk" line 214: XXX: Should not reach word1
+make: "directive-for.mk" line 214: XXX: Should not reach before--after
+make: "directive-for.mk" line 214: XXX: Should not reach word3
 make: "directive-for.mk" line 219: no iteration variables in for
 make: "directive-for.mk" line 245: 1 open conditional
 	in .for loop from directive-for.mk:243 with var = value
@@ -38,7 +38,7 @@ For: loop body with outer = o:
    endfor
 For: end for 1
 For: loop body with inner = i:
-make: "directive-for.mk" line 318: newline-item=(a)
+make: "directive-for.mk" line 319: newline-item=(a)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.23 src/usr.bin/make/unit-tests/varmod-edge.exp:1.24
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.23	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Jul  6 10:14:35 2024
@@ -1,31 +1,11 @@
-make: "varmod-edge.mk" line 186: ok M-paren
-make: "varmod-edge.mk" line 186: ok M-mixed
-make: "varmod-edge.mk" line 186: ok M-unescape
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.M-nest-mix" with value "${INP.M-nest-mix:M${:U*)}}": while evaluating variable "INP.M-nest-mix" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)"
-	in .for loop from varmod-edge.mk:164 with test = M-nest-mix
-make: "varmod-edge.mk" line 186: ok M-nest-mix
-make: "varmod-edge.mk" line 186: ok M-nest-brk
-make: "varmod-edge.mk" line 186: ok M-pat-err
-make: "varmod-edge.mk" line 186: ok M-bsbs
-make: "varmod-edge.mk" line 186: ok M-bs1-par
-make: "varmod-edge.mk" line 186: ok M-bs2-par
-make: "varmod-edge.mk" line 186: ok M-128
-make: "varmod-edge.mk" line 186: ok eq-ext
-make: "varmod-edge.mk" line 186: ok eq-q
-make: "varmod-edge.mk" line 186: ok eq-bs
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.eq-esc" with value "${INP.eq-esc:a\=b}": while evaluating variable "INP.eq-esc" with value "file.c file...": Unfinished modifier ('=' missing)
-	in .for loop from varmod-edge.mk:164 with test = eq-esc
-make: "varmod-edge.mk" line 186: ok eq-esc
-make: "varmod-edge.mk" line 186: ok colon
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "value": Unknown modifier ":"
-	in .for loop from varmod-edge.mk:164 with test = colons
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "": Unknown modifier ":"
-	in .for loop from varmod-edge.mk:164 with test = colons
-make: "varmod-edge.mk" line 186: ok colons
-make: "varmod-edge.mk" line 197: while evaluating "${:Z}" with value "": Unknown modifier "Z"
-make: "varmod-edge.mk" line 197: Malformed conditional (${:Z})
-make: "varmod-edge.mk" line 211: while evaluating "${:S,}" with value "": Unfinished modifier (',' missing)
-make: "varmod-edge.mk" line 211: Malformed conditional (${:S,})
+make: "varmod-edge.mk" line 60: while evaluating variable "MOD" with value "${INP:M${:U*)}}": while evaluating variable "INP" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)"
+make: "varmod-edge.mk" line 178: while evaluating variable "MOD" with value "${INP:a\=b}": while evaluating variable "INP" with value "file.c file...": Unfinished modifier ('=' missing)
+make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP::::}": while evaluating variable "INP" with value "value": Unknown modifier ":"
+make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP::::}": while evaluating variable "INP" with value "": Unknown modifier ":"
+make: "varmod-edge.mk" line 203: while evaluating "${:Z}" with value "": Unknown modifier "Z"
+make: "varmod-edge.mk" line 203: Malformed conditional (${:Z})
+make: "varmod-edge.mk" line 217: while evaluating "${:S,}" with value "": Unfinished modifier (',' missing)
+make: "varmod-edge.mk" line 217: Malformed conditional (${:S,})
 make: Fatal errors encountered -- cannot continue
-make: stopped making "all" in unit-tests
+make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.25 src/usr.bin/make/unit-tests/varmod-edge.mk:1.26
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.25	Fri Jul  5 19:47:22 2024
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Jul  6 10:14:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.25 2024/07/05 19:47:22 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.26 2024/07/06 10:14:35 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -10,19 +10,23 @@
 # - MOD, the expression for testing the modifier
 # - EXP, the expected output
 
-TESTS+=		M-paren
-INP.M-paren=	(parentheses) {braces} (opening closing) ()
-MOD.M-paren=	${INP.M-paren:M(*)}
-EXP.M-paren=	(parentheses) ()
+INP=	(parentheses) {braces} (opening closing) ()
+MOD=	${INP:M(*)}
+EXP=	(parentheses) ()
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The first closing brace matches the opening parenthesis.
 # The second closing brace actually ends the expression.
 #
 # XXX: This is unexpected but rarely occurs in practice.
-TESTS+=		M-mixed
-INP.M-mixed=	(paren-brace} (
-MOD.M-mixed=	${INP.M-mixed:M(*}}
-EXP.M-mixed=	(paren-brace}
+INP=	(paren-brace} (
+MOD=	${INP:M(*}}
+EXP=	(paren-brace}
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # After the :M modifier has parsed the pattern, only the closing brace
 # and the colon are unescaped. The other characters are left as-is.
@@ -31,10 +35,12 @@ EXP.M-mixed=	(paren-brace}
 # Str_Match.
 #
 # XXX: This is unexpected. The opening brace should also be unescaped.
-TESTS+=		M-unescape
-INP.M-unescape=	({}): \(\{\}\)\: \(\{}\):
-MOD.M-unescape=	${INP.M-unescape:M\\(\\{\\}\\)\\:}
-EXP.M-unescape=	\(\{}\):
+INP=	({}): \(\{\}\)\: \(\{}\):
+MOD=	${INP:M\\(\\{\\}\\)\\:}
+EXP=	\(\{}\):
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # When the :M and :N modifiers are parsed, the pattern finishes as soon
 # as open_parens + open_braces == closing_parens + closing_braces. This
@@ -47,21 +53,26 @@ EXP.M-unescape=	\(\{}\):
 # The final brace in the output comes from the end of M.nest-mix.
 #
 # XXX: This is unexpected but rarely occurs in practice.
-TESTS+=		M-nest-mix
-INP.M-nest-mix=	(parentheses)
-MOD.M-nest-mix=	${INP.M-nest-mix:M${:U*)}}
-EXP.M-nest-mix=	(parentheses)}
+INP=	(parentheses)
+MOD=	${INP:M${:U*)}}
+EXP=	(parentheses)}
+# expect+1: while evaluating variable "MOD" with value "${INP:M${:U*)}}": while evaluating variable "INP" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)"
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 
 # In contrast to parentheses and braces, the brackets are not counted
-# when the :M modifier is parsed since Makefile variables only take the
+# when the :M modifier is parsed since Makefile expressions only take the
 # ${VAR} or $(VAR) forms, but not $[VAR].
 #
 # The final ] in the pattern is needed to close the character class.
-TESTS+=		M-nest-brk
-INP.M-nest-brk=	[ [[ [[[
-MOD.M-nest-brk=	${INP.M-nest-brk:M${:U[[[[[]}}
-EXP.M-nest-brk=	[
+INP=	[ [[ [[[
+MOD=	${INP:M${:U[[[[[]}}
+EXP=	[
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The pattern in the nested variable has an unclosed character class.
 # No error is reported though, and the pattern is closed implicitly.
@@ -71,26 +82,30 @@ EXP.M-nest-brk=	[
 #
 # Before 2019-12-02, this test case triggered an out-of-bounds read
 # in Str_Match.
-TESTS+=		M-pat-err
-INP.M-pat-err=	[ [[ [[[
-MOD.M-pat-err=	${INP.M-pat-err:M${:U[[}}
-EXP.M-pat-err=	[
+INP=	[ [[ [[[
+MOD=	${INP:M${:U[[}}
+EXP=	[
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The first backslash does not escape the second backslash.
 # Therefore, the second backslash escapes the parenthesis.
 # This means that the pattern ends there.
-# The final } in the output comes from the end of MOD.M-bsbs.
+# The final } in the output comes from the end of MOD.
 #
 # If the first backslash were to escape the second backslash, the first
-# closing brace would match the opening parenthesis (see M-mixed), and
+# closing brace would match the opening parenthesis (see paren-brace), and
 # the second closing brace would be needed to close the variable.
 # After that, the remaining backslash would escape the parenthesis in
 # the pattern, therefore (} would match.
-TESTS+=		M-bsbs
-INP.M-bsbs=	(} \( \(}
-MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
-EXP.M-bsbs=	\(}
-#EXP.M-bsbs=	(}	# If the first backslash were to escape ...
+INP=	(} \( \(}
+MOD=	${INP:M\\(}}
+EXP=	\(}
+#EXP=	(}	# If the first backslash were to escape ...
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The backslash in \( does not escape the parenthesis, therefore it
 # counts for the nesting level and matches with the first closing brace.
@@ -99,95 +114,86 @@ EXP.M-bsbs=	\(}
 #
 # The second :M in the pattern is nested between ( and }, therefore it
 # does not start a new modifier.
-TESTS+=		M-bs1-par
-INP.M-bs1-par=	( (:M (:M} \( \(:M \(:M}
-MOD.M-bs1-par=	${INP.M-bs1-par:M\(:M*}}}
-EXP.M-bs1-par=	(:M}}
+INP=	( (:M (:M} \( \(:M \(:M}
+MOD=	${INP:M\(:M*}}}
+EXP=	(:M}}
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The double backslash is passed verbatim to the pattern matcher.
 # The Str_Match pattern is \\(:M*}, and there the backslash is unescaped.
 # Again, the ( takes place in the nesting level, and there is no way to
 # prevent this, no matter how many backslashes are used.
-TESTS+=		M-bs2-par
-INP.M-bs2-par=	( (:M (:M} \( \(:M \(:M}
-MOD.M-bs2-par=	${INP.M-bs2-par:M\\(:M*}}}
-EXP.M-bs2-par=	\(:M}}
-
-# Str_Match uses a recursive algorithm for matching the * patterns.
-# Make sure that it survives patterns with 128 asterisks.
-# That should be enough for all practical purposes.
-# To produce a stack overflow, just add more :Qs below.
-TESTS+=		M-128
-INP.M-128=	${:U\\:Q:Q:Q:Q:Q:Q:Q:S,\\,x,g}
-PAT.M-128=	${:U\\:Q:Q:Q:Q:Q:Q:Q:S,\\,*,g}
-MOD.M-128=	${INP.M-128:M${PAT.M-128}}
-EXP.M-128=	${INP.M-128}
+INP=	( (:M (:M} \( \(:M \(:M}
+MOD=	${INP:M\\(:M*}}}
+EXP=	\(:M}}
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
+
+# Before str.c 1.48 from 2020-06-15, Str_Match used a recursive algorithm for
+# matching the '*' patterns and did not optimize for multiple '*' in a row.
+# Test a pattern with 65536 asterisks.
+INP=	${:U\\:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:S,\\,x,g}
+PAT=	${:U\\:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:Q:S,\\,*,g}
+MOD=	${INP:M${PAT}}
+EXP=	${INP}
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # This is the normal SysV substitution. Nothing surprising here.
-TESTS+=		eq-ext
-INP.eq-ext=	file.c file.cc
-MOD.eq-ext=	${INP.eq-ext:%.c=%.o}
-EXP.eq-ext=	file.o file.cc
+INP=	file.c file.cc
+MOD=	${INP:%.c=%.o}
+EXP=	file.o file.cc
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The SysV := modifier is greedy and consumes all the modifier text
 # up until the closing brace or parenthesis. The :Q may look like a
 # modifier, but it really isn't, that's why it appears in the output.
-TESTS+=		eq-q
-INP.eq-q=	file.c file.cc
-MOD.eq-q=	${INP.eq-q:%.c=%.o:Q}
-EXP.eq-q=	file.o:Q file.cc
+INP=	file.c file.cc
+MOD=	${INP:%.c=%.o:Q}
+EXP=	file.o:Q file.cc
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # The = in the := modifier can be escaped.
-TESTS+=		eq-bs
-INP.eq-bs=	file.c file.c=%.o
-MOD.eq-bs=	${INP.eq-bs:%.c\=%.o=%.ext}
-EXP.eq-bs=	file.c file.ext
+INP=	file.c file.c=%.o
+MOD=	${INP:%.c\=%.o=%.ext}
+EXP=	file.c file.ext
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # Having only an escaped '=' results in a parse error.
 # The call to "pattern.lhs = ParseModifierPart" fails.
-TESTS+=		eq-esc
-INP.eq-esc=	file.c file...
-MOD.eq-esc=	${INP.eq-esc:a\=b}
-EXP.eq-esc=	# empty
-# make: Unfinished modifier for INP.eq-esc ('=' missing)
-
-TESTS+=		colon
-INP.colon=	value
-MOD.colon=	${INP.colon:}
-EXP.colon=	value
-
-TESTS+=		colons
-INP.colons=	value
-MOD.colons=	${INP.colons::::}
-EXP.colons=	# empty
-
-.for test in ${TESTS}
-# expect+3: while evaluating variable "MOD.eq-esc" with value "${INP.eq-esc:a\=b}": while evaluating variable "INP.eq-esc" with value "file.c file...": Unfinished modifier ('=' missing)
-# expect+2: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "value": Unknown modifier ":"
-# expect+1: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "": Unknown modifier ":"
-.  if ${MOD.${test}} == ${EXP.${test}}
-# expect+17: ok M-paren
-# expect+16: ok M-mixed
-# expect+15: ok M-unescape
-# expect-4: while evaluating variable "MOD.M-nest-mix" with value "${INP.M-nest-mix:M${:U*)}}": while evaluating variable "INP.M-nest-mix" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)"
-# expect+13: ok M-nest-mix
-# expect+12: ok M-nest-brk
-# expect+11: ok M-pat-err
-# expect+10: ok M-bsbs
-# expect+09: ok M-bs1-par
-# expect+08: ok M-bs2-par
-# expect+07: ok M-128
-# expect+06: ok eq-ext
-# expect+05: ok eq-q
-# expect+04: ok eq-bs
-# expect+03: ok eq-esc
-# expect+02: ok colon
-# expect+01: ok colons
-.    info ok ${test}
-.  else
-.    warning error in ${test}: expected "${EXP.${test}}", got "${MOD.${test}}"
-.  endif
-.endfor
+INP=	file.c file...
+MOD=	${INP:a\=b}
+EXP=	# empty
+# expect+1: while evaluating variable "MOD" with value "${INP:a\=b}": while evaluating variable "INP" with value "file.c file...": Unfinished modifier ('=' missing)
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
+
+INP=	value
+MOD=	${INP:}
+EXP=	value
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
+
+INP=	value
+MOD=	${INP::::}
+EXP=	# empty
+# expect+2: while evaluating variable "MOD" with value "${INP::::}": while evaluating variable "INP" with value "value": Unknown modifier ":"
+# expect+1: while evaluating variable "MOD" with value "${INP::::}": while evaluating variable "INP" with value "": Unknown modifier ":"
+.if ${MOD} != ${EXP}
+.  warning expected "${EXP}", got "${MOD}"
+.endif
 
 # Even in expressions based on an unnamed variable, there may be errors.
 # XXX: The error message should mention the variable name of the expression,
@@ -213,6 +219,3 @@ EXP.colons=	# empty
 .else
 .  error
 .endif
-
-all:
-	@echo ok

Reply via email to