xref: /freebsd/contrib/bmake/unit-tests/cond-eof.mk (revision 66fd12cf4896eb08ad8e7a2627537f84ead84dd3)
1# $NetBSD: cond-eof.mk,v 1.5 2023/06/01 20:56:35 rillig Exp $
2#
3# Tests for parsing the end of '.if' conditions, which are represented as the
4# token TOK_EOF.
5
6
7SIDE_EFFECT=	${:!echo 'side effect' 1>&2!}
8SIDE_EFFECT2=	${:!echo 'side effect 2' 1>&2!}
9
10# In the following conditions, ${SIDE_EFFECT} is the position of the first
11# parse error.  Before cond.c 1.286 from 2021-12-10, it was always fully
12# evaluated, even if it was not necessary to expand the variable expression.
13# These syntax errors are an edge case that does not occur during normal
14# operation.  Still, it is easy to avoid evaluating these expressions, just in
15# case they have side effects.
16# expect+1: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2})
17.if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2}
18.endif
19# expect+1: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2})
20.if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2}
21.endif
22# expect+1: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2})
23.if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2}
24.endif
25