xref: /freebsd-src/contrib/bmake/unit-tests/cond-eof.mk (revision d5e0a182cf153f8993a633b93d9220c99a89e760)
1*d5e0a182SSimon J. Gerraty# $NetBSD: cond-eof.mk,v 1.6 2023/11/19 21:47:52 rillig Exp $
206b9b3e0SSimon J. Gerraty#
3148ee845SSimon J. Gerraty# Tests for parsing the end of '.if' conditions, which are represented as the
4148ee845SSimon J. Gerraty# token TOK_EOF.
5148ee845SSimon J. Gerraty
606b9b3e0SSimon J. Gerraty
706b9b3e0SSimon J. GerratySIDE_EFFECT=	${:!echo 'side effect' 1>&2!}
806b9b3e0SSimon J. GerratySIDE_EFFECT2=	${:!echo 'side effect 2' 1>&2!}
906b9b3e0SSimon J. Gerraty
1006b9b3e0SSimon J. Gerraty# In the following conditions, ${SIDE_EFFECT} is the position of the first
1112904384SSimon J. Gerraty# parse error.  Before cond.c 1.286 from 2021-12-10, it was always fully
12*d5e0a182SSimon J. Gerraty# evaluated, even if it was not necessary to expand the expression.
1312904384SSimon J. Gerraty# These syntax errors are an edge case that does not occur during normal
1412904384SSimon J. Gerraty# operation.  Still, it is easy to avoid evaluating these expressions, just in
1512904384SSimon J. Gerraty# case they have side effects.
16148ee845SSimon J. Gerraty# expect+1: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2})
1706b9b3e0SSimon J. Gerraty.if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2}
1806b9b3e0SSimon J. Gerraty.endif
19148ee845SSimon J. Gerraty# expect+1: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2})
2006b9b3e0SSimon J. Gerraty.if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2}
2106b9b3e0SSimon J. Gerraty.endif
22148ee845SSimon J. Gerraty# expect+1: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2})
2306b9b3e0SSimon J. Gerraty.if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2}
2406b9b3e0SSimon J. Gerraty.endif
25