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