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 empty variable...



details:   https://anonhg.NetBSD.org/src/rev/2f866f82906b
branches:  trunk
changeset: 954899:2f866f82906b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 13 07:32:32 2020 +0000

description:
make(1): add test for empty variable name in :@var@...@ modifier

diffstat:

 usr.bin/make/unit-tests/varmod-loop.exp |  1 +
 usr.bin/make/unit-tests/varmod-loop.mk  |  7 ++++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diffs (32 lines):

diff -r dbfb71ee9185 -r 2f866f82906b usr.bin/make/unit-tests/varmod-loop.exp
--- a/usr.bin/make/unit-tests/varmod-loop.exp   Sun Sep 13 06:36:54 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-loop.exp   Sun Sep 13 07:32:32 2020 +0000
@@ -3,6 +3,7 @@
 :x1y x2y x3y:
 :mod-loop-varname: :x1y x2y x3y: ::
 :x1y x2y x3y:
+empty: :xy xy xy:
 mod-loop-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
 mod-loop-varname-dollar:(1) (2) (3).
 mod-loop-varname-dollar:() () ().
diff -r dbfb71ee9185 -r 2f866f82906b usr.bin/make/unit-tests/varmod-loop.mk
--- a/usr.bin/make/unit-tests/varmod-loop.mk    Sun Sep 13 06:36:54 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-loop.mk    Sun Sep 13 07:32:32 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-loop.mk,v 1.2 2020/08/16 12:30:45 rillig Exp $
+# $NetBSD: varmod-loop.mk,v 1.3 2020/09/13 07:32:32 rillig Exp $
 #
 # Tests for the :@var@...${var}...@ variable modifier.
 
@@ -27,6 +27,11 @@
        # It needs to be doubled though.
        @echo :${:U1 2 3:@\\@x${${:Ux:S,x,\\,}}y@}:
 
+       # The variable name can technically be empty, and in this situation
+       # the variable value cannot be accessed since the empty variable is
+       # protected to always return an empty string.
+       @echo empty: :${:U1 2 3:@@x${}y@}:
+
 # The :@ modifier resolves the variables a little more often than expected.
 # In particular, it resolves _all_ variables from the context, and not only
 # the loop variable (in this case v).



Home | Main Index | Thread Index | Old Index