Skip to content

Commit

Permalink
add a few more function scope tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbardin committed Nov 1, 2023
1 parent 83c95d2 commit 1ce4917
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion hclsyntax/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,36 @@ upper(
cty.StringVal("FOO"),
0,
},
{
`::upper("foo")`, // :: is still not a valid identifier
&hcl.EvalContext{
Functions: map[string]function.Function{
"::upper": stdlib.UpperFunc,
},
},
cty.DynamicVal,
1,
},
{
`double::::upper("foo")`, // missing name after ::
&hcl.EvalContext{
Functions: map[string]function.Function{
"double::::upper": stdlib.UpperFunc,
},
},
cty.NilVal,
1,
},
{
`missing::("foo")`, // missing name after ::
&hcl.EvalContext{
Functions: map[string]function.Function{
"missing::": stdlib.UpperFunc,
},
},
cty.NilVal,
1,
},
{
`misbehave()`,
&hcl.EvalContext{
Expand Down Expand Up @@ -2194,8 +2224,12 @@ EOT
for _, test := range tests {
t.Run(test.input, func(t *testing.T) {
expr, parseDiags := ParseExpression([]byte(test.input), "", hcl.Pos{Line: 1, Column: 1, Byte: 0})
var got cty.Value
var valDiags hcl.Diagnostics

got, valDiags := expr.Value(test.ctx)
if expr != nil {
got, valDiags = expr.Value(test.ctx)
}

diagCount := len(parseDiags) + len(valDiags)

Expand Down

0 comments on commit 1ce4917

Please sign in to comment.