Home | History | Annotate | Line # | Download | only in unit-tests
var-op-append.mk revision 1.8
      1  1.8  rillig # $NetBSD: var-op-append.mk,v 1.8 2021/02/03 08:40:47 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for the += variable assignment operator, which appends to a variable,
      4  1.2  rillig # creating it if necessary.
      5  1.1  rillig 
      6  1.5  rillig # Appending to an undefined variable is possible.
      7  1.5  rillig # The variable is created, and no extra space is added before the value.
      8  1.5  rillig VAR+=	one
      9  1.5  rillig .if ${VAR} != "one"
     10  1.5  rillig .  error
     11  1.5  rillig .endif
     12  1.5  rillig 
     13  1.5  rillig # Appending to an existing variable adds a single space and the value.
     14  1.5  rillig VAR+=	two
     15  1.5  rillig .if ${VAR} != "one two"
     16  1.5  rillig .  error
     17  1.5  rillig .endif
     18  1.5  rillig 
     19  1.5  rillig # Appending an empty string nevertheless adds a single space.
     20  1.5  rillig VAR+=	# empty
     21  1.5  rillig .if ${VAR} != "one two "
     22  1.5  rillig .  error
     23  1.5  rillig .endif
     24  1.5  rillig 
     25  1.5  rillig # Variable names may contain '+', and this character is also part of the
     26  1.5  rillig # '+=' assignment operator.  As far as possible, the '+' is interpreted as
     27  1.5  rillig # part of the assignment operator.
     28  1.5  rillig #
     29  1.5  rillig # See Parse_DoVar
     30  1.6  rillig C++=	value
     31  1.5  rillig .if ${C+} != "value" || defined(C++)
     32  1.5  rillig .  error
     33  1.5  rillig .endif
     34  1.1  rillig 
     35  1.8  rillig # Before var.c 1.793 from 2021-02-03, the variable name of a newly created
     36  1.8  rillig # variable was expanded two times in a row, which was unexpected but
     37  1.8  rillig # irrelevant in practice since variable names containing dollars lead to
     38  1.8  rillig # strange side effects in several other places as well.
     39  1.7  rillig .MAKEFLAGS: -dv
     40  1.7  rillig VAR.${:U\$\$\$\$\$\$\$\$}+=	dollars
     41  1.7  rillig .MAKEFLAGS: -d0
     42  1.8  rillig .if ${VAR.${:U\$\$\$\$\$\$\$\$}} != "dollars"
     43  1.7  rillig .  error
     44  1.7  rillig .endif
     45  1.7  rillig 
     46  1.1  rillig all:
     47