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

Function TestTraversalStatic

hclsyntax/expression_static_test.go:14–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestTraversalStatic(t *testing.T) {
15 expr, diags := ParseExpression([]byte(`a.b.c`), "", hcl.Pos{Line: 1, Column: 1})
16 got, moreDiags := hcl.AbsTraversalForExpr(expr)
17 diags = append(diags, moreDiags...)
18
19 if len(diags) != 0 {
20 t.Errorf("wrong number of diags %d; want 0", len(diags))
21 for _, diag := range diags {
22 t.Logf("- %s", diag)
23 }
24 return
25 }
26
27 want := hcl.Traversal{
28 hcl.TraverseRoot{
29 Name: "a",
30 SrcRange: hcl.Range{
31 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},
32 End: hcl.Pos{Line: 1, Column: 2, Byte: 1},
33 },
34 },
35 hcl.TraverseAttr{
36 Name: "b",
37 SrcRange: hcl.Range{
38 Start: hcl.Pos{Line: 1, Column: 2, Byte: 1},
39 End: hcl.Pos{Line: 1, Column: 4, Byte: 3},
40 },
41 },
42 hcl.TraverseAttr{
43 Name: "c",
44 SrcRange: hcl.Range{
45 Start: hcl.Pos{Line: 1, Column: 4, Byte: 3},
46 End: hcl.Pos{Line: 1, Column: 6, Byte: 5},
47 },
48 },
49 }
50
51 for _, problem := range deep.Equal(got, want) {
52 t.Error(problem)
53 }
54}
55
56func TestTupleStatic(t *testing.T) {
57 expr, diags := ParseExpression([]byte(`[true, false]`), "", hcl.Pos{Line: 1, Column: 1})

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
ParseExpressionFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected