136 lines · plain
1# Empty values are permitted and reasonable, especially when just establishing2# expansion order.3#4# DEFINE: %{empty}=5# RUN: echo "'%{empty}'"6# CHECK:# | ''7#8# REDEFINE: %{empty}=9# RUN: echo "'%{empty}'"10# CHECK:# | ''11 12# A value consisting only of whitespace is trimmed to the empty string.13#14# v~~ intentional whitespace15# DEFINE: %{ws}= 16# RUN: echo "'%{ws}'"17# CHECK:# | ''18#19# v intentional whitespace20# REDEFINE: %{ws}= 21# RUN: echo "'%{ws}'"22# CHECK:# | ''23 24# Whitespace is not required around the name or value.25#26# DEFINE:%{no-whitespace}=abc27# RUN: echo "'%{no-whitespace}'"28# CHECK:# | 'abc'29#30# REDEFINE:%{no-whitespace}=HelloWorld31# RUN: echo "'%{no-whitespace}'"32# CHECK:# | 'HelloWorld'33 34# Whitespace is not required between substitutions in a value.35#36# DEFINE: %{adjacent0} = foo37# DEFINE: %{adjacent1} = bar38# DEFINE: %{has-adjacent-substs} = %{adjacent0}%{adjacent1}39# RUN: echo "'%{has-adjacent-substs}'"40# CHECK:# | 'foobar'41#42# REDEFINE: %{has-adjacent-substs} = %{adjacent0}%{adjacent1}%{adjacent0}43# RUN: echo "'%{has-adjacent-substs}'"44# CHECK:# | 'foobarfoo'45 46# Exact whitespace is preserved within the value, but whitespace enclosing the47# name or value is discarded. ('%{' and '}' are part of the name, and48# whitespace in between isn't permitted.)49#50# v~~ intentional whitespace51# DEFINE: %{whitespace} = abc def 52# RUN: echo "'%{whitespace}'"53# CHECK:# | 'abc def'54# v intentional whitespace55# REDEFINE: %{whitespace} = Hello World 56# RUN: echo "'%{whitespace}'"57# CHECK:# | 'Hello World'58 59# Line continuations in the value are permitted and collapse whitespace.60#61# DEFINE: %{continue} = abc\62# DEFINE:def \63# DEFINE:ghi\64# DEFINE: jkl \65# DEFINE: mno \66# DEFINE: pqr 67# ^ intentional whitespace68# RUN: echo "'%{continue}'"69# CHECK:# | 'abc def ghi jkl mno pqr'70#71# REDEFINE: %{continue} = abc \72# REDEFINE: def73# RUN: echo "'%{continue}'"74# CHECK:# | 'abc def'75 76# Whitespace at the end of the line after a '\' is ignored, and it's treated as77# a line continuation. Otherwise, the behavior would be hard to understand78# because it looks like a line continuation.79#80# v~~~~~~~~~~~ intentional whitespace81# DEFINE: %{ws-after-continue}=foo \ 82# DEFINE: bar \ 83# ^ intentional whitespace84# DEFINE: baz85# RUN: echo "'%{ws-after-continue}'"86# CHECK:# | 'foo bar baz'87#88# v intentional whitespace89# REDEFINE: %{ws-after-continue}=foo \ 90# REDEFINE: bar \ 91# ^~~~~~~~~~~~ intentional whitespace92# REDEFINE: baz93# RUN: echo "'%{ws-after-continue}'"94# CHECK:# | 'foo bar baz'95 96# A line continuation is recognized anywhere. It should be used only where97# whitespace is permitted because it reduces to a single space.98#99# Directives with at least one non-whitespace character (could be '\') are100# permitted even if they contribute nothing to the value. There might be no101# practical use, but check that it behaves as expected.102#103# DEFINE:\104# DEFINE:%{blank-lines}\105# DEFINE:\106# DEFINE:=\107# DEFINE:\108# DEFINE:a109# RUN: echo "'%{blank-lines}'"110# CHECK:# | 'a'111#112# REDEFINE: \113# REDEFINE: %{blank-lines} \114# REDEFINE: \115# REDEFINE: = \116# REDEFINE: \117# REDEFINE: a \118# REDEFINE: \119# REDEFINE: b \120# REDEFINE: \121# REDEFINE: c122# RUN: echo "'%{blank-lines}'"123# CHECK:# | 'a b c'124 125# The fourth DEFINE line is deceptive because it looks like a new substitution,126# but it's actually a continuation of the previous value.127#128# DEFINE: %{name}=x129# DEFINE: %{value}=3130# DEFINE: %{deceptive-continue}=echo \131# DEFINE: %{name}=%{value}132# RUN: %{deceptive-continue}133# CHECK:# | x=3134 135# CHECK:{{ *}}Passed: 1 {{\([0-9]*\.[0-9]*%\)}}136