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 test for common and edg...



details:   https://anonhg.NetBSD.org/src/rev/3dec03d19437
branches:  trunk
changeset: 1017564:3dec03d19437
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 31 14:26:37 2020 +0000

description:
make(1): add test for common and edge cases in .for loop expansion

diffstat:

 usr.bin/make/unit-tests/directive-for-escape.exp |  22 ++++++++++++++++++++++
 usr.bin/make/unit-tests/directive-for-escape.mk  |  19 ++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletions(-)

diffs (62 lines):

diff -r 6d7a963d11d6 -r 3dec03d19437 usr.bin/make/unit-tests/directive-for-escape.exp
--- a/usr.bin/make/unit-tests/directive-for-escape.exp  Thu Dec 31 14:10:04 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.exp  Thu Dec 31 14:26:37 2020 +0000
@@ -46,6 +46,28 @@
 For: loop body:
 .  info ${:Ureplaced}
 make: "directive-for-escape.mk" line 78: replaced
+For: end for 1
+For: loop body:
+.  info .        $$i: ${:Uinner}
+.  info .      $${i}: ${:Uinner}
+.  info .   $${i:M*}: ${:Uinner:M*}
+.  info .      $$(i): $(:Uinner)
+.  info .   $$(i:M*): $(:Uinner:M*)
+.  info . $${i$${:U}}: ${i${:U}}
+.  info .    $${i\}}: ${:Uinner\}}     # XXX: unclear why SubstVarLong needs this
+.  info .     $${i2}: ${i2}
+.  info .     $${i,}: ${i,}
+.  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
+make: "directive-for-escape.mk" line 86: .        $i: inner
+make: "directive-for-escape.mk" line 87: .      ${i}: inner
+make: "directive-for-escape.mk" line 88: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 89: .      $(i): inner
+make: "directive-for-escape.mk" line 90: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 91: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 92: .    ${i\}}: inner}
+make: "directive-for-escape.mk" line 93: .     ${i2}: two
+make: "directive-for-escape.mk" line 94: .     ${i,}: comma
+make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
 make: no target to make.
 
 make: stopped in unit-tests
diff -r 6d7a963d11d6 -r 3dec03d19437 usr.bin/make/unit-tests/directive-for-escape.mk
--- a/usr.bin/make/unit-tests/directive-for-escape.mk   Thu Dec 31 14:10:04 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.mk   Thu Dec 31 14:26:37 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.2 2020/12/31 13:23:43 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.3 2020/12/31 14:26:37 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
@@ -77,3 +77,20 @@
 .for BASENAME}${EXT in replaced
 .  info ${BASENAME}${EXT}
 .endfor
+
+# Demonstrate the various ways to refer to the iteration variable.
+i=             outer
+i2=            two
+i,=            comma
+.for i in inner
+.  info .        $$i: $i
+.  info .      $${i}: ${i}
+.  info .   $${i:M*}: ${i:M*}
+.  info .      $$(i): $(i)
+.  info .   $$(i:M*): $(i:M*)
+.  info . $${i$${:U}}: ${i${:U}}
+.  info .    $${i\}}: ${i\}}   # XXX: unclear why SubstVarLong needs this
+.  info .     $${i2}: ${i2}
+.  info .     $${i,}: ${i,}
+.  info .  adjacent: $i${i}${i:M*}$i
+.endfor



Home | Main Index | Thread Index | Old Index