xref: /src/contrib/bmake/unit-tests/cond-eof.mk (revision a8c56be47166295d37600ff81fc1857db87b3a9b)
13d772e59SSimon J. Gerraty# $NetBSD: cond-eof.mk,v 1.8 2025/06/28 22:39:28 rillig Exp $
28e11a9b4SSimon J. Gerraty#
33e39ce56SSimon J. Gerraty# Tests for parsing the end of '.if' conditions, which are represented as the
43e39ce56SSimon J. Gerraty# token TOK_EOF.
53e39ce56SSimon J. Gerraty
68e11a9b4SSimon J. Gerraty
78e11a9b4SSimon J. GerratySIDE_EFFECT=	${:!echo 'side effect' 1>&2!}
88e11a9b4SSimon J. GerratySIDE_EFFECT2=	${:!echo 'side effect 2' 1>&2!}
98e11a9b4SSimon J. Gerraty
108e11a9b4SSimon J. Gerraty# In the following conditions, ${SIDE_EFFECT} is the position of the first
112935fe82SSimon J. Gerraty# parse error.  Before cond.c 1.286 from 2021-12-10, it was always fully
127a05a715SSimon J. Gerraty# evaluated, even if it was not necessary to expand the expression.
132935fe82SSimon J. Gerraty# These syntax errors are an edge case that does not occur during normal
142935fe82SSimon J. Gerraty# operation.  Still, it is easy to avoid evaluating these expressions, just in
152935fe82SSimon J. Gerraty# case they have side effects.
163d772e59SSimon J. Gerraty# expect+1: Malformed conditional "0 ${SIDE_EFFECT} ${SIDE_EFFECT2}"
178e11a9b4SSimon J. Gerraty.if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2}
188e11a9b4SSimon J. Gerraty.endif
193d772e59SSimon J. Gerraty# expect+1: Malformed conditional "1 ${SIDE_EFFECT} ${SIDE_EFFECT2}"
208e11a9b4SSimon J. Gerraty.if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2}
218e11a9b4SSimon J. Gerraty.endif
223d772e59SSimon J. Gerraty# expect+1: Malformed conditional "(0) ${SIDE_EFFECT} ${SIDE_EFFECT2}"
238e11a9b4SSimon J. Gerraty.if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2}
248e11a9b4SSimon J. Gerraty.endif
25