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