Home | History | Annotate | Line # | Download | only in unit-tests
varmod-range.mk revision 1.4
      1  1.4  rillig # $NetBSD: varmod-range.mk,v 1.4 2020/09/27 18:11:31 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for the :range variable modifier, which generates sequences
      4  1.2  rillig # of integers from the given range.
      5  1.1  rillig 
      6  1.4  rillig # The :range modifier generates a sequence of integers, one number per
      7  1.4  rillig # word of the variable expression's value.
      8  1.4  rillig .if ${a b c:L:range} != "1 2 3"
      9  1.4  rillig .  error
     10  1.4  rillig .endif
     11  1.4  rillig 
     12  1.4  rillig # To preserve spaces in a word, they can be enclosed in quotes, just like
     13  1.4  rillig # everywhere else.
     14  1.4  rillig .if ${:U first "the second word" third 4 :range} != "1 2 3 4"
     15  1.4  rillig .  error
     16  1.4  rillig .endif
     17  1.4  rillig 
     18  1.4  rillig # The :range modifier takes the number of words from the value of the
     19  1.4  rillig # variable expression.  If that expression is undefined, the range is
     20  1.4  rillig # undefined as well.  This should not come as a surprise.
     21  1.4  rillig .if "${:range}" != ""
     22  1.4  rillig .  error
     23  1.4  rillig .endif
     24  1.4  rillig 
     25  1.4  rillig # The :range modifier can be given a parameter, which makes the generated
     26  1.4  rillig # range independent from the value or the name of the variable expression.
     27  1.4  rillig #
     28  1.4  rillig # XXX: As of 2020-09-27, the :range=... modifier does not turn the undefined
     29  1.4  rillig # expression into a defined one.  This looks like an oversight.
     30  1.4  rillig .if "${:range=5}" != ""
     31  1.4  rillig .  error
     32  1.4  rillig .endif
     33  1.4  rillig 
     34  1.1  rillig all:
     35  1.3  rillig 	@echo ${a b c:L:rang}			# modifier name too short
     36  1.3  rillig 	@echo ${a b c:L:range}			# ok
     37  1.3  rillig 	@echo ${a b c:L:rango}			# misspelled
     38  1.3  rillig 	@echo ${a b c:L:ranger}			# modifier name too long
     39