MCPcopy
hub / github.com/hashicorp/hcl / TestStaticExpressionList

Function TestStaticExpressionList

hclsyntax/expression_test.go:2920–2936  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2918}
2919
2920func TestStaticExpressionList(t *testing.T) {
2921 expr, _ := ParseExpression([]byte("[0, a, true]"), "", hcl.Pos{})
2922 exprs, diags := hcl.ExprList(expr)
2923 if len(diags) != 0 {
2924 t.Fatalf("unexpected diagnostics:\n%s", diags.Error())
2925 }
2926 if len(exprs) != 3 {
2927 t.Fatalf("wrong result %#v; want length 3", exprs)
2928 }
2929 first, ok := exprs[0].(*LiteralValueExpr)
2930 if !ok {
2931 t.Fatalf("first expr has wrong type %T; want *hclsyntax.LiteralValueExpr", exprs[0])
2932 }
2933 if !first.Val.RawEquals(cty.Zero) {
2934 t.Fatalf("wrong first value %#v; want cty.Zero", first.Val)
2935 }
2936}
2937
2938// Check that function call w/ incomplete argument still reports correct range
2939func TestParseExpression_incompleteFunctionCall(t *testing.T) {

Callers

nothing calls this directly

Calls 3

ParseExpressionFunction · 0.70
ExprListMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected