make(1): move tests for the :tu and :_ modifiers into separate files

This commit is contained in:
rillig 2020-08-23 15:18:43 +00:00
parent 2070e56d26
commit 13749176b7
6 changed files with 16 additions and 28 deletions

View File

@ -14,11 +14,8 @@ C:
S:empty
C:empty
@:
mod-tu-space: A B
mod-quote: new
line
mod-break-many-words: 500
mod-remember: 1 2 3 1 2 3 1 2 3
mod-remember: 1 2 3, SAVED=3
exit status 0

View File

@ -1,4 +1,4 @@
# $Id: modmisc.mk,v 1.45 2020/08/23 15:13:21 rillig Exp $
# $Id: modmisc.mk,v 1.46 2020/08/23 15:18:43 rillig Exp $
#
# miscellaneous modifier tests
@ -16,10 +16,8 @@ MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
MOD_SEP=S,:, ,g
all: modvar modvarloop modsysv emptyvar undefvar
all: mod-tu-space
all: mod-quote
all: mod-break-many-words
all: mod-remember
# See also sysv.mk.
modsysv:
@ -58,11 +56,6 @@ undefvar:
@echo C:${:U:C,^$,empty,}
@echo @:${:U:@var@empty@}
mod-tu-space:
# The :tu and :tl modifiers operate on the variable value
# as a single string, not as a list of words. Therefore,
# the adjacent spaces are preserved.
@echo $@: ${a b:L:tu:Q}
mod-quote:
@echo $@: new${.newline:Q}${.newline:Q}line
@ -71,14 +64,6 @@ mod-quote:
mod-break-many-words:
@echo $@: ${UNDEF:U:range=500:[#]}
# Demonstrate the :_ modifier.
# In the parameterized form, having the variable name on the right side
# of the = assignment operator is confusing. Luckily this modifier is
# only rarely needed.
mod-remember:
@echo $@: ${1 2 3:L:_:@var@${_}@}
@echo $@: ${1 2 3:L:@var@${var:_=SAVED:}@}, SAVED=${SAVED}
# To apply a modifier indirectly via another variable, the whole
# modifier must be put into a single variable.
.if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}"

View File

@ -1 +1,3 @@
1 2 3 1 2 3 1 2 3
1 2 3, SAVED=3
exit status 0

View File

@ -1,9 +1,12 @@
# $NetBSD: varmod-remember.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
# $NetBSD: varmod-remember.mk,v 1.3 2020/08/23 15:18:43 rillig Exp $
#
# Tests for the :_ modifier, which saves the current variable value
# in the _ variable or another, to be used later again.
# TODO: Implementation
# In the parameterized form, having the variable name on the right side of
# the = assignment operator is confusing. In almost all other situations
# the variable name is on the left-hand side of the = operator. Luckily
# this modifier is only rarely needed.
all:
@:;
@echo ${1 2 3:L:_:@var@${_}@}
@echo ${1 2 3:L:@var@${var:_=SAVED:}@}, SAVED=${SAVED}

View File

@ -1 +1,2 @@
mod-tu-space: A B
exit status 0

View File

@ -1,9 +1,9 @@
# $NetBSD: varmod-to-upper.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
# $NetBSD: varmod-to-upper.mk,v 1.3 2020/08/23 15:18:43 rillig Exp $
#
# Tests for the :tu variable modifier, which returns the words in the
# variable value, converted to uppercase.
# TODO: Implementation
all:
@:;
# The :tu and :tl modifiers operate on the variable value as a single string,
# not as a list of words. Therefore, the adjacent spaces are preserved.
mod-tu-space:
@echo $@: ${a b:L:tu:Q}