xref: /freebsd/contrib/bmake/unit-tests/varmod-l-name-to-value.mk (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1# $NetBSD: varmod-l-name-to-value.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $
2#
3# Tests for the :L modifier, which returns the variable name as the new value.
4
5# The empty variable name leads to an empty string.
6.if ${:L} != ""
7.  error
8.endif
9
10# The variable name is converted into an expression with the variable name
11# "VARNAME" and the value "VARNAME".
12.if ${VARNAME:L} != "VARNAME"
13.  error
14.endif
15
16# The value of the expression can be modified afterwards.
17.if ${VARNAME:L:S,VAR,,} != "NAME"
18.  error
19.endif
20
21# The name of the expression is still the same as before. Using the :L
22# modifier, it can be restored.
23#
24# Hmmm, this can be used as a double storage or a backup mechanism.
25# Probably unintended, but maybe useful.
26.if ${VARNAME:L:S,VAR,,:L} != "VARNAME"
27.  error
28.endif
29
30# Between 2020-09-22 (var.c 1.527) and 2020-09-30 (var.c 1.553), there was
31# a bug in the evaluation of expressions.  Indirect modifiers like
32# the below :L did not update the definedness of the enclosing expression.
33# This resulted in a wrong "Malformed conditional".
34.if ${value:${:UL}} == ""
35.endif
36
37# As of 2020-10-02, the :L modifier does not ensure that it is followed by
38# a delimiter, that is, a ':' or endc.  Neither does the :P modifier.
39.if ${value:LLLLLLPL} != "value"
40.  error
41.endif
42
43all:
44	@:;
45