hclsyntax: Additional tests for template sequence escapes

In previous versions we had some bugs around template sequence escapes.
These tests show that they no longer seem to be present, and should
hopefully avoid them regressing in future.
This commit is contained in:
Martin Atkins 2019-09-11 15:50:56 -07:00
parent 22ba006718
commit 2c66cf702c

View File

@ -84,6 +84,12 @@ hello world
cty.StringVal("hello $$nonescape"),
0,
},
{
`hello %${"world"}`,
nil,
cty.StringVal("hello %world"),
0,
},
{
`${true}`,
nil,
@ -253,6 +259,30 @@ trim`,
cty.StringVal("%%"),
0,
},
{
`hello %%{ if true }world%%{ endif }`,
nil,
cty.StringVal(`hello %{ if true }world%{ endif }`),
0,
},
{
`hello $%{ if true }world%{ endif }`,
nil,
cty.StringVal("hello $world"),
0,
},
{
`%{ endif }`,
nil,
cty.UnknownVal(cty.String),
1, // Unexpected endif directive
},
{
`%{ endfor }`,
nil,
cty.UnknownVal(cty.String),
1, // Unexpected endfor directive
},
}
for _, test := range tests {