hcl/hclsyntax: Tests for normal (non-flush) heredoc expressions

This commit is contained in:
Martin Atkins 2018-12-13 11:59:00 -08:00
parent b056768a1c
commit c33bbe4c25

View File

@ -1101,6 +1101,69 @@ upper(
cty.StringVal("hello"),
0,
},
{
`
<<EOT
Foo
Bar
Baz
EOT
`,
nil,
cty.StringVal("Foo\nBar\nBaz\n"),
0,
},
{
`
<<EOT
Foo
${bar}
Baz
EOT
`,
&hcl.EvalContext{
Variables: map[string]cty.Value{
"bar": cty.StringVal("Bar"),
},
},
cty.StringVal("Foo\nBar\nBaz\n"),
0,
},
{
`
<<EOT
Foo
%{for x in bars}${x}%{endfor}
Baz
EOT
`,
&hcl.EvalContext{
Variables: map[string]cty.Value{
"bars": cty.ListVal([]cty.Value{
cty.StringVal("Bar"),
cty.StringVal("Bar"),
cty.StringVal("Bar"),
}),
},
},
cty.StringVal("Foo\nBarBarBar\nBaz\n"),
0,
},
{
`[
<<EOT
Foo
Bar
Baz
EOT
]
`,
nil,
cty.TupleVal([]cty.Value{cty.StringVal(" Foo\n Bar\n Baz\n")}),
0,
},
{
`unk["baz"]`,
&hcl.EvalContext{