xref: /freebsd/contrib/bmake/unit-tests/cond-func.mk (revision 7ec2f6bce5d28e6662c29e63f6ab6b7ef57d98b2)
1# $NetBSD: cond-func.mk,v 1.1 2020/08/20 17:45:47 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
9DEF=			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 after the opening parenthesis is ignored.
19.if !defined( 	DEF)
20.error
21.endif
22
23# Horizontal whitespace 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
62all:
63	@:;
64