From 2c66cf702c6169be22322ecbdd1dff5bd6dbbfbc Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 11 Sep 2019 15:50:56 -0700 Subject: [PATCH] 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. --- hclsyntax/expression_template_test.go | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hclsyntax/expression_template_test.go b/hclsyntax/expression_template_test.go index aed9e41..81dda0b 100644 --- a/hclsyntax/expression_template_test.go +++ b/hclsyntax/expression_template_test.go @@ -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 {