Module Name: src
Committed By: rillig
Date: Sun Jul 19 20:49:45 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk
Log Message:
make(1): add tests for the ::= modifiers
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.18 src/usr.bin/make/unit-tests/modmisc.exp:1.19
--- src/usr.bin/make/unit-tests/modmisc.exp:1.18 Sun Jul 19 19:36:20 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp Sun Jul 19 20:49:44 2020
@@ -70,4 +70,12 @@ make: No subexpression \2
mod-C-limits:22-missing:1 6
mod-C-limits:22-ok:1 33 556
mod-C-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
+mod-assign: first=1.
+mod-assign: last=3.
+mod-assign: appended=1 2 3.
+1
+2
+3
+mod-assign: ran:3.
+mod-assign: global: 1, 3, 1 2 3, 3.
exit status 0
Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.15 src/usr.bin/make/unit-tests/modmisc.mk:1.16
--- src/usr.bin/make/unit-tests/modmisc.mk:1.15 Sun Jul 19 19:36:20 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk Sun Jul 19 20:49:44 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.15 2020/07/19 19:36:20 rillig Exp $
+# $Id: modmisc.mk,v 1.16 2020/07/19 20:49:44 rillig Exp $
#
# miscellaneous modifier tests
@@ -19,6 +19,7 @@ all: modvar modvarloop modsysv mod-HTE e
all: mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar
all: mod-subst-dollar mod-loop-dollar
all: mod-C-limits
+all: mod-assign
modsysv:
@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@@ -145,3 +146,13 @@ mod-C-limits:
# The :C modifier only handles single-digit capturing groups,
# which is more than enough for daily use.
@echo $@:capture:${:UabcdefghijABCDEFGHIJrest:C,(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.),\9\8\7\6\5\4\3\2\1\0\10\11\12,}
+
+# Just a bit of basic code coverage for the obscure ::= assignment modifiers.
+mod-assign:
+ @echo $@: ${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}.
+ @echo $@: ${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}.
+ @echo $@: ${1 2 3:L:@i@${APPENDED::+=$i}@} appended=${APPENDED}.
+ @echo $@: ${echo.1 echo.2 echo.3:L:@i@${RAN::!=${i:C,.*,&; & 1>\&2,:S,., ,g}}@} ran:${RAN}.
+ # The assignments happen in the global scope and thus are
+ # preserved even after the shell command has been run.
+ @echo $@: global: ${FIRST:Q}, ${LAST:Q}, ${APPENDED:Q}, ${RAN:Q}.