Home | History | Annotate | Line # | Download | only in unit-tests
varmod-l-name-to-value.mk revision 1.4
      1 # $NetBSD: varmod-l-name-to-value.mk,v 1.4 2020/09/30 05:42:06 rillig Exp $
      2 #
      3 # Tests for the :L modifier, which returns the variable name as the new value.
      4 
      5 # The empty variable name leads to an empty string.
      6 .if ${:L} != ""
      7 .error
      8 .endif
      9 
     10 # The variable name is converted into an expression with the variable name
     11 # "VARNAME" and the value "VARNAME".
     12 .if ${VARNAME:L} != "VARNAME"
     13 .error
     14 .endif
     15 
     16 # The value of the expression can be modified afterwards.
     17 .if ${VARNAME:L:S,VAR,,} != "NAME"
     18 .error
     19 .endif
     20 
     21 # The name of the expression is still the same as before. Using the :L
     22 # modifier, it can be restored.
     23 #
     24 # Hmmm, this can be used as a double storage or a backup mechanism.
     25 # Probably unintended, but maybe useful.
     26 .if ${VARNAME:L:S,VAR,,:L} != "VARNAME"
     27 .error
     28 .endif
     29 
     30 # Between 2020-09-22 (var.c 1.527) and 2020-09-30 (var.c 1.554), there was
     31 # a bug in the evaluation of variable expression.  Indirect modifiers like
     32 # this :L did not update the definedness of the enclosing expression.
     33 # This resulted in a wrong "Malformed variable".
     34 .if ${value:${:UL}} == ""
     35 .endif
     36 
     37 all:
     38 	@:;
     39