diff options
Diffstat (limited to 'contrib/bmake/unit-tests/varmod-sysv.mk')
-rw-r--r-- | contrib/bmake/unit-tests/varmod-sysv.mk | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/contrib/bmake/unit-tests/varmod-sysv.mk b/contrib/bmake/unit-tests/varmod-sysv.mk index 712c1731717b..9209626cc214 100644 --- a/contrib/bmake/unit-tests/varmod-sysv.mk +++ b/contrib/bmake/unit-tests/varmod-sysv.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-sysv.mk,v 1.14 2021/04/12 16:09:57 rillig Exp $ +# $NetBSD: varmod-sysv.mk,v 1.24 2025/03/30 00:35:52 rillig Exp $ # # Tests for the variable modifier ':from=to', which replaces the suffix # "from" with "to". It can also use '%' as a wildcard. @@ -49,7 +49,7 @@ . error .endif -# In the modifier ':from=to', both parts can contain variable expressions. +# In the modifier ':from=to', both parts can contain expressions. .if ${one two:L:${:Uone}=${:U1}} != "1 two" . error .endif @@ -69,7 +69,7 @@ .endif # The replacement string can contain spaces, thereby changing the number -# of words in the variable expression. +# of words in the expression. .if ${In:L:%=% ${:Uthe Sun}} != "In the Sun" . error .endif @@ -206,12 +206,13 @@ . error .endif -# This is not a SysV modifier since the nested variable expression expands +# This is not a SysV modifier since the nested expression expands # to an empty string. The '=' in it should be irrelevant during parsing. -# XXX: As of 2020-12-05, this expression generates an "Unfinished modifier" +# XXX: As of 2024-06-30, this expression generates an "Unfinished modifier" # error, while the correct error message would be "Unknown modifier" since # there is no modifier named "fromto". -.if ${word214:L:from${:D=}to} +# expect+1: Unfinished modifier after "from${:D=}to}", expecting "=" +.if ${word216:L:from${:D=}to} . error .endif @@ -220,7 +221,7 @@ # "fromto}...". The next modifier is a SysV modifier. ApplyModifier_SysV # parses the modifier as "from${:D=}to", ending at the '}'. Next, the two # parts of the modifier are parsed using ParseModifierPart, which scans -# differently, properly handling nested variable expressions. The two parts +# differently, properly handling nested expressions. The two parts # are now "fromto}..." and "replaced". .if "${:Ufromto\}...:from${:D=}to}...=replaced}" != "replaced" . error @@ -251,4 +252,35 @@ INDIRECT= 1:${VALUE} 2:$${VALUE} 4:$$$${VALUE} . endfor .endfor + +# The error case of an unfinished ':from=to' modifier after the '=' requires +# an expression that is missing the closing '}'. +# expect+1: Unfinished modifier after "$(})", expecting "}" +.if ${error:L:from=$(}) +.endif + + +# The various ":t..." modifiers fall back to the ":from=to" modifier. +.if ${:Utarget:target=source} != "source" +. error +.endif +.if ${:Ufile.ts:ts=js} != "file.js" +. error +.endif +.if ${:Ufile.tsx:tsx=jsx} != "file.jsx" +. error +.endif +.if ${:Ufile.ts\\part:ts\part=replaced} != "file.replaced" +. error +.endif +.if ${:Ufile.ts\\123xyz:ts\123xyz=gone} != "file.gone" +. error +.endif +# Since the ":ts=" modifier is a valid form of the ":ts" modifier, don't fall +# back to the ":from=to" modifier. +.if ${:U1 2 3 file.ts:ts=} != "1=2=3=file.ts" +. error +.endif + + all: |