xref: /freebsd/contrib/bmake/unit-tests/varparse-errors.mk (revision e2eeea75eb8b6dd50c1298067a0655880d186734)
1*e2eeea75SSimon J. Gerraty# $NetBSD: varparse-errors.mk,v 1.1 2020/11/08 16:44:47 rillig Exp $
2*e2eeea75SSimon J. Gerraty
3*e2eeea75SSimon J. Gerraty# Tests for parsing and evaluating all kinds of variable expressions.
4*e2eeea75SSimon J. Gerraty#
5*e2eeea75SSimon J. Gerraty# This is the basis for redesigning the error handling in Var_Parse and
6*e2eeea75SSimon J. Gerraty# Var_Subst, collecting typical and not so typical use cases.
7*e2eeea75SSimon J. Gerraty#
8*e2eeea75SSimon J. Gerraty# See also:
9*e2eeea75SSimon J. Gerraty#	VarParseResult
10*e2eeea75SSimon J. Gerraty#	Var_Parse
11*e2eeea75SSimon J. Gerraty#	Var_Subst
12*e2eeea75SSimon J. Gerraty
13*e2eeea75SSimon J. GerratyPLAIN=		plain value
14*e2eeea75SSimon J. Gerraty
15*e2eeea75SSimon J. GerratyLITERAL_DOLLAR=	To get a dollar, double $$ it.
16*e2eeea75SSimon J. Gerraty
17*e2eeea75SSimon J. GerratyINDIRECT=	An ${:Uindirect} value.
18*e2eeea75SSimon J. Gerraty
19*e2eeea75SSimon J. GerratyREF_UNDEF=	A reference to an ${UNDEF}undefined variable.
20*e2eeea75SSimon J. Gerraty
21*e2eeea75SSimon J. GerratyERR_UNCLOSED=	An ${UNCLOSED variable expression.
22*e2eeea75SSimon J. Gerraty
23*e2eeea75SSimon J. GerratyERR_BAD_MOD=	An ${:Uindirect:Z} expression with an unknown modifier.
24*e2eeea75SSimon J. Gerraty
25*e2eeea75SSimon J. GerratyERR_EVAL=	An evaluation error ${:Uvalue:C,.,\3,}.
26*e2eeea75SSimon J. Gerraty
27*e2eeea75SSimon J. Gerraty# In a conditional, a variable expression that is not enclosed in quotes is
28*e2eeea75SSimon J. Gerraty# expanded using the flags VARE_UNDEFERR and VARE_WANTRES.
29*e2eeea75SSimon J. Gerraty# The variable itself must be defined.
30*e2eeea75SSimon J. Gerraty# It may refer to undefined variables though.
31*e2eeea75SSimon J. Gerraty.if ${REF_UNDEF} != "A reference to an undefined variable."
32*e2eeea75SSimon J. Gerraty.  error
33*e2eeea75SSimon J. Gerraty.endif
34*e2eeea75SSimon J. Gerraty
35*e2eeea75SSimon J. Gerratyall:
36