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 the ::= modif...
details: https://anonhg.NetBSD.org/src/rev/6f92f91b3a69
branches: trunk
changeset: 936137:6f92f91b3a69
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 19 20:49:44 2020 +0000
description:
make(1): add tests for the ::= modifiers
diffstat:
usr.bin/make/unit-tests/modmisc.exp | 8 ++++++++
usr.bin/make/unit-tests/modmisc.mk | 13 ++++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diffs (47 lines):
diff -r 4223437fd5a6 -r 6f92f91b3a69 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp Sun Jul 19 20:37:57 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp Sun Jul 19 20:49:44 2020 +0000
@@ -70,4 +70,12 @@
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
diff -r 4223437fd5a6 -r 6f92f91b3a69 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk Sun Jul 19 20:37:57 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk Sun Jul 19 20:49:44 2020 +0000
@@ -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: 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 @@
# 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}.
Home |
Main Index |
Thread Index |
Old Index