xref: /freebsd/contrib/bmake/unit-tests/directive-for-empty.exp (revision 8d5c8e21c690b35d0a9a604d6b886fba222cd2fe)
1148ee845SSimon J. Gerratymake: "directive-for-empty.mk" line 22: 2
2954401e6SSimon J. GerratyFor: end for 1
3148ee845SSimon J. GerratyFor: loop body with i = value:
4954401e6SSimon J. Gerraty# The identifier 'empty' can only be used in conditions such as .if, .ifdef or
5954401e6SSimon J. Gerraty# .elif.  In other lines the string 'empty(' must be preserved.
6954401e6SSimon J. GerratyCPPFLAGS+=	-Dmessage="empty(i)"
7954401e6SSimon J. Gerraty# There may be whitespace between 'empty' and '('.
8954401e6SSimon J. Gerraty.if ! empty (i)
9954401e6SSimon J. Gerraty.  error
10954401e6SSimon J. Gerraty.endif
11954401e6SSimon J. Gerraty# Even in conditions, the string 'empty(' is not always a function call, it
12954401e6SSimon J. Gerraty# can occur in a string literal as well.
13954401e6SSimon J. Gerraty.if "empty\(i)" != "empty(i)"
14954401e6SSimon J. Gerraty.  error
15954401e6SSimon J. Gerraty.endif
16954401e6SSimon J. Gerraty# In comments like 'empty(i)', the text must be preserved as well.
17954401e6SSimon J. Gerraty#
18954401e6SSimon J. Gerraty# Conditions, including function calls to 'empty', can not only occur in
19954401e6SSimon J. Gerraty# condition directives, they can also occur in the modifier ':?', see
20954401e6SSimon J. Gerraty# varmod-ifelse.mk.
21954401e6SSimon J. GerratyCPPFLAGS+=	-Dmacro="${empty(i):?empty:not-empty}"
22*8d5c8e21SSimon J. Gerratyexit status 0
23