Home | History | Annotate | Line # | Download | only in unit-tests
cond-func.mk revision 1.2
      1  1.2  rillig # $NetBSD: cond-func.mk,v 1.2 2020/09/23 08:11:28 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for those parts of the functions in .if conditions that are common
      4  1.1  rillig # among several functions.
      5  1.1  rillig #
      6  1.1  rillig # The below test uses the function defined(...) since it has no side-effects,
      7  1.1  rillig # the other functions (except empty(...)) would work equally well.
      8  1.1  rillig 
      9  1.1  rillig DEF=			defined
     10  1.1  rillig ${:UA B}=		variable name with spaces
     11  1.1  rillig ${:UVAR(value)}=	variable name with parentheses
     12  1.1  rillig ${:UVAR{value}}=	variable name with braces
     13  1.1  rillig 
     14  1.1  rillig .if !defined(DEF)
     15  1.1  rillig .error
     16  1.1  rillig .endif
     17  1.1  rillig 
     18  1.1  rillig # Horizontal whitespace after the opening parenthesis is ignored.
     19  1.1  rillig .if !defined( 	DEF)
     20  1.1  rillig .error
     21  1.1  rillig .endif
     22  1.1  rillig 
     23  1.1  rillig # Horizontal whitespace before the closing parenthesis is ignored.
     24  1.1  rillig .if !defined(DEF 	)
     25  1.1  rillig .error
     26  1.1  rillig .endif
     27  1.1  rillig 
     28  1.1  rillig # The argument of a function must not directly contain whitespace.
     29  1.1  rillig .if !defined(A B)
     30  1.1  rillig .error
     31  1.1  rillig .endif
     32  1.1  rillig 
     33  1.1  rillig # If necessary, the whitespace can be generated by a variable expression.
     34  1.1  rillig .if !defined(${:UA B})
     35  1.1  rillig .error
     36  1.1  rillig .endif
     37  1.1  rillig 
     38  1.1  rillig # Characters that could be mistaken for operators must not appear directly
     39  1.1  rillig # in a function argument.  As with whitespace, these can be generated
     40  1.1  rillig # indirectly.
     41  1.1  rillig #
     42  1.1  rillig # It's not entirely clear why these characters are forbidden.
     43  1.1  rillig # The most plausible reason seems to be typo detection.
     44  1.1  rillig .if !defined(A&B)
     45  1.1  rillig .error
     46  1.1  rillig .endif
     47  1.1  rillig .if !defined(A|B)
     48  1.1  rillig .error
     49  1.1  rillig .endif
     50  1.1  rillig 
     51  1.1  rillig # Even parentheses may appear in variable names.
     52  1.1  rillig # They must be balanced though.
     53  1.1  rillig .if !defined(VAR(value))
     54  1.1  rillig .error
     55  1.1  rillig .endif
     56  1.1  rillig 
     57  1.1  rillig # Braces do not have any special meaning when parsing arguments.
     58  1.1  rillig .if !defined(VAR{value})
     59  1.1  rillig .error
     60  1.1  rillig .endif
     61  1.1  rillig 
     62  1.2  rillig # There may be spaces around the operators and parentheses, and even
     63  1.2  rillig # inside the parentheses.  The spaces inside the parentheses are not
     64  1.2  rillig # allowed for the empty() function (see cond-func-empty.mk), therefore
     65  1.2  rillig # they are typically omitted for the other functions as well.
     66  1.2  rillig .if ! defined ( DEF )
     67  1.2  rillig .  error
     68  1.2  rillig .endif
     69  1.2  rillig 
     70  1.1  rillig all:
     71  1.1  rillig 	@:;
     72