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 tests for dollar charac...



details:   https://anonhg.NetBSD.org/src/rev/3a3a3315a457
branches:  trunk
changeset: 935526:3a3a3315a457
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 04 18:54:18 2020 +0000

description:
make(1): add tests for dollar characters in modifiers

diffstat:

 usr.bin/make/unit-tests/modmisc.exp |  16 ++++++++++++++++
 usr.bin/make/unit-tests/modmisc.mk  |  34 +++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 1 deletions(-)

diffs (76 lines):

diff -r 977c2dcf1d88 -r 3a3a3315a457 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp       Sat Jul 04 18:07:31 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp       Sat Jul 04 18:54:18 2020 +0000
@@ -32,4 +32,20 @@
 :x__ 3 x__ 3:
 :+one+ +two+ +three+:
 mod-at-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
+mod-subst-dollar:$1:
+mod-subst-dollar:$2:
+mod-subst-dollar:$3:
+mod-subst-dollar:$4:
+mod-subst-dollar:$5:
+mod-subst-dollar:$6:
+mod-subst-dollar:$7:
+mod-subst-dollar:$8:
+mod-subst-dollar:U8:
+mod-subst-dollar:$$$$:
+mod-loop-dollar:1:
+mod-loop-dollar:${word}:
+mod-loop-dollar:$3$:
+mod-loop-dollar:$${word}$:
+mod-loop-dollar:$$5$$:
+mod-loop-dollar:$$${word}$$:
 exit status 0
diff -r 977c2dcf1d88 -r 3a3a3315a457 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk        Sat Jul 04 18:07:31 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk        Sat Jul 04 18:54:18 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.11 2020/07/04 17:41:04 rillig Exp $
+# $Id: modmisc.mk,v 1.12 2020/07/04 18:54:18 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -17,6 +17,7 @@
 
 all:   modvar modvarloop modsysv mod-HTE emptyvar undefvar
 all:   mod-S mod-C mod-at-varname mod-at-resolve
+all:   mod-subst-dollar mod-loop-dollar
 
 modsysv:
        @echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@@ -93,3 +94,34 @@
 
 mod-at-resolve:
        @echo $@:${RESOLVE:@v@w${v}w@:Q}:
+
+# No matter how many dollar characters there are, they all get merged
+# into a single dollar by the :S modifier.
+mod-subst-dollar:
+       @echo $@:${:U1:S,^,$,:Q}:
+       @echo $@:${:U2:S,^,$$,:Q}:
+       @echo $@:${:U3:S,^,$$$,:Q}:
+       @echo $@:${:U4:S,^,$$$$,:Q}:
+       @echo $@:${:U5:S,^,$$$$$,:Q}:
+       @echo $@:${:U6:S,^,$$$$$$,:Q}:
+       @echo $@:${:U7:S,^,$$$$$$$,:Q}:
+       @echo $@:${:U8:S,^,$$$$$$$$,:Q}:
+# This generates no dollar at all:
+       @echo $@:${:UU8:S,^,${:U$$$$$$$$},:Q}:
+# Here is an alternative way to generate dollar characters.
+# It's unexpectedly complicated though.
+       @echo $@:${:U:range=5:ts\x24:C,[0-9],,g:Q}:
+
+# Demonstrate that it is possible to generate dollar characters using the
+# :@ modifier.
+#
+# These are edge cases that could have resulted in a parse error as well
+# since the $@ at the end could have been interpreted as a variable, which
+# would mean a missing closing @ delimiter.
+mod-loop-dollar:
+       @echo $@:${:U1:@word@${word}$@:Q}:
+       @echo $@:${:U2:@word@$${word}$$@:Q}:
+       @echo $@:${:U3:@word@$$${word}$$$@:Q}:
+       @echo $@:${:U4:@word@$$$${word}$$$$@:Q}:
+       @echo $@:${:U5:@word@$$$$${word}$$$$$@:Q}:
+       @echo $@:${:U6:@word@$$$$$${word}$$$$$$@:Q}:



Home | Main Index | Thread Index | Old Index