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 the :L modifier



details:   https://anonhg.NetBSD.org/src/rev/bbe96d65a917
branches:  trunk
changeset: 943081:bbe96d65a917
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Aug 25 22:25:05 2020 +0000

description:
make(1): add test for the :L modifier

diffstat:

 usr.bin/make/unit-tests/varmod-l-name-to-value.mk |  27 +++++++++++++++++++++-
 1 files changed, 25 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r 30635da5ec5e -r bbe96d65a917 usr.bin/make/unit-tests/varmod-l-name-to-value.mk
--- a/usr.bin/make/unit-tests/varmod-l-name-to-value.mk Tue Aug 25 21:58:08 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-l-name-to-value.mk Tue Aug 25 22:25:05 2020 +0000
@@ -1,8 +1,31 @@
-# $NetBSD: varmod-l-name-to-value.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-l-name-to-value.mk,v 1.3 2020/08/25 22:25:05 rillig Exp $
 #
 # Tests for the :L modifier, which returns the variable name as the new value.
 
-# TODO: Implementation
+# The empty variable name leads to an empty string.
+.if ${:L} != ""
+.error
+.endif
+
+# The variable name is converted into an expression with the variable name
+# "VARNAME" and the value "VARNAME".
+.if ${VARNAME:L} != "VARNAME"
+.error
+.endif
+
+# The value of the expression can be modified afterwards.
+.if ${VARNAME:L:S,VAR,,} != "NAME"
+.error
+.endif
+
+# The name of the expression is still the same as before. Using the :L
+# modifier, it can be restored.
+#
+# Hmmm, this can be used as a double storage or a backup mechanism.
+# Probably unintended, but maybe useful.
+.if ${VARNAME:L:S,VAR,,:L} != "VARNAME"
+.error
+.endif
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index