(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestTemplateExprParseAndValue(t *testing.T) { |
| 15 | // This is a combo test that exercises both the parser and the Value |
| 16 | // method, with the focus on the latter but indirectly testing the former. |
| 17 | tests := []struct { |
| 18 | input string |
| 19 | ctx *hcl.EvalContext |
| 20 | want cty.Value |
| 21 | diagCount int |
| 22 | }{ |
| 23 | { |
| 24 | `1`, |
| 25 | nil, |
| 26 | cty.StringVal("1"), |
| 27 | 0, |
| 28 | }, |
| 29 | { |
| 30 | `(1)`, |
| 31 | nil, |
| 32 | cty.StringVal("(1)"), |
| 33 | 0, |
| 34 | }, |
| 35 | { |
| 36 | `true`, |
| 37 | nil, |
| 38 | cty.StringVal("true"), |
| 39 | 0, |
| 40 | }, |
| 41 | { |
| 42 | ` |
| 43 | hello world |
| 44 | `, |
| 45 | nil, |
| 46 | cty.StringVal("\nhello world\n"), |
| 47 | 0, |
| 48 | }, |
| 49 | { |
| 50 | `hello ${"world"}`, |
| 51 | nil, |
| 52 | cty.StringVal("hello world"), |
| 53 | 0, |
| 54 | }, |
| 55 | { |
| 56 | `hello\nworld`, // backslash escapes not supported in bare templates |
| 57 | nil, |
| 58 | cty.StringVal("hello\\nworld"), |
| 59 | 0, |
| 60 | }, |
| 61 | { |
| 62 | `hello ${12.5}`, |
| 63 | nil, |
| 64 | cty.StringVal("hello 12.5"), |
| 65 | 0, |
| 66 | }, |
| 67 | { |
| 68 | `silly ${"${"nesting"}"}`, |
| 69 | nil, |
| 70 | cty.StringVal("silly nesting"), |
| 71 | 0, |
nothing calls this directly
no test coverage detected