diff options
Diffstat (limited to 'contrib/bmake/unit-tests/var-eval-short.mk')
-rw-r--r-- | contrib/bmake/unit-tests/var-eval-short.mk | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/contrib/bmake/unit-tests/var-eval-short.mk b/contrib/bmake/unit-tests/var-eval-short.mk index 41782f0d7823..2b25d82e96b8 100644 --- a/contrib/bmake/unit-tests/var-eval-short.mk +++ b/contrib/bmake/unit-tests/var-eval-short.mk @@ -1,12 +1,13 @@ -# $NetBSD: var-eval-short.mk,v 1.5 2021/04/04 13:35:26 rillig Exp $ +# $NetBSD: var-eval-short.mk,v 1.11 2023/10/19 18:24:33 rillig Exp $ # # Tests for each variable modifier to ensure that they only do the minimum -# necessary computations. If the result of the expression is not needed, they -# should only parse the modifier but not actually evaluate it. +# necessary computations. If the result of the expression is irrelevant, +# the modifier should only be parsed. The modifier should not be evaluated, +# but if it is evaluated for simplicity of the code (such as ':ts'), it must +# not have any observable side effects. # # See also: # var.c, the comment starting with 'The ApplyModifier functions' -# ApplyModifier, for the order of the modifiers # ParseModifierPart, for evaluating nested expressions # cond-short.mk @@ -17,6 +18,8 @@ FAIL= ${:!echo unexpected 1>&2!} # is ignored as well. To do that, it is necessary to step through the code of # each modifier. +# TODO: Test the modifiers in the same order as they occur in ApplyModifier. + .if 0 && ${FAIL} .endif @@ -38,19 +41,21 @@ FAIL= ${:!echo unexpected 1>&2!} # after the loop, when undefining the temporary global loop variable. # Since var.c 1.907 from 2021-04-04, a '$' is no longer allowed in the # variable name. +# expect+2: In the :@ modifier of "", the variable name "${FAIL}" must not contain a dollar +# expect+1: Malformed conditional (0 && ${:Uword:@${FAIL}@expr@}) .if 0 && ${:Uword:@${FAIL}@expr@} .endif .if 0 && ${:Uword:@var@${FAIL}@} .endif -# Before var.c,v 1.877 from 2021-03-14, the modifier ':[...]' did not expand +# Before var.c 1.877 from 2021-03-14, the modifier ':[...]' did not expand # the nested expression ${FAIL} and then tried to parse the unexpanded text, # which failed since '$' is not a valid range character. .if 0 && ${:Uword:[${FAIL}]} .endif -# Before var.c,v 1.867 from 2021-03-14, the modifier ':_' defined the variable +# Before var.c 1.867 from 2021-03-14, the modifier ':_' defined the variable # even though the whole expression should have only been parsed, not # evaluated. .if 0 && ${:Uword:_=VAR} @@ -58,11 +63,13 @@ FAIL= ${:!echo unexpected 1>&2!} . error .endif -# Before var.c,v 1.856 from 2021-03-14, the modifier ':C' did not expand the -# nested expression ${FAIL} and then tried to compile the unexpanded text as a -# regular expression, which failed both because of the '{FAIL}', which is not -# a valid repetition, and because of the '****', which are repeated -# repetitions as well. +# Before var.c 1.856 from 2021-03-14, the modifier ':C' did not expand the +# nested expression ${FAIL}, which is correct, and then tried to compile the +# unexpanded text as a regular expression, which is unnecessary since the +# right-hand side of the '&&' cannot influence the outcome of the condition. +# Compiling the regular expression then failed both because of the '{FAIL}', +# which is not a valid repetition of the form '{1,5}', and because of the +# '****', which are repeated repetitions as well. # '${FAIL}' .if 0 && ${:Uword:C,${FAIL}****,,} .endif @@ -74,8 +81,9 @@ DEFINED= # defined .if 0 && ${:Uword:E} .endif -# As of 2021-03-14, the error 'Invalid time value: ${FAIL}}' is ok since -# ':gmtime' does not expand its argument. +# Before var.c 1.1050 from 2023-05-09, the ':gmtime' modifier produced the +# error message 'Invalid time value: ${FAIL}}' since it did not expand its +# argument. .if 0 && ${:Uword:gmtime=${FAIL}} .endif @@ -88,8 +96,9 @@ DEFINED= # defined .if 0 && ${value:L} .endif -# As of 2021-03-14, the error 'Invalid time value: ${FAIL}}' is ok since -# ':localtime' does not expand its argument. +# Before var.c 1.1050 from 2023-05-09, the ':localtime' modifier produced the +# error message 'Invalid time value: ${FAIL}}' since it did not expand its +# argument. .if 0 && ${:Uword:localtime=${FAIL}} .endif |