Home | History | Annotate | Line # | Download | only in unit-tests
varmod-remember.mk revision 1.5
      1  1.5  rillig # $NetBSD: varmod-remember.mk,v 1.5 2021/03/14 17:14:15 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for the :_ modifier, which saves the current variable value
      4  1.2  rillig # in the _ variable or another, to be used later again.
      5  1.1  rillig 
      6  1.4  rillig .if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
      7  1.4  rillig .  error
      8  1.4  rillig .endif
      9  1.4  rillig 
     10  1.3  rillig # In the parameterized form, having the variable name on the right side of
     11  1.3  rillig # the = assignment operator is confusing.  In almost all other situations
     12  1.3  rillig # the variable name is on the left-hand side of the = operator.  Luckily
     13  1.3  rillig # this modifier is only rarely needed.
     14  1.4  rillig .if ${1 2 3:L:@var@${var:_=SAVED:}@} != "1 2 3"
     15  1.4  rillig .  error
     16  1.4  rillig .elif ${SAVED} != "3"
     17  1.4  rillig .  error
     18  1.4  rillig .endif
     19  1.4  rillig 
     20  1.5  rillig # The ':_' modifier takes a variable name as optional argument.  This variable
     21  1.5  rillig # name can refer to other variables, though this was rather an implementation
     22  1.5  rillig # oversight than an intended feature.  The variable name stops at the first
     23  1.5  rillig # '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
     24  1.5  rillig # names.
     25  1.5  rillig S=	INDIRECT_VARNAME
     26  1.5  rillig .if ${value:L:@var@${var:_=$S}@} != "value"
     27  1.5  rillig .  error
     28  1.5  rillig .elif ${INDIRECT_VARNAME} != "value"
     29  1.5  rillig .  error
     30  1.5  rillig .endif
     31  1.5  rillig 
     32  1.1  rillig all:
     33