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

Function TestParseTraversalAbs

hclsyntax/parse_traversal_test.go:16–309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestParseTraversalAbs(t *testing.T) {
17 tests := []struct {
18 src string
19 want hcl.Traversal
20 diagCount int
21 }{
22 {
23 "",
24 nil,
25 1, // variable name required
26 },
27 {
28 "foo",
29 hcl.Traversal{
30 hcl.TraverseRoot{
31 Name: "foo",
32 SrcRange: hcl.Range{
33 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},
34 End: hcl.Pos{Line: 1, Column: 4, Byte: 3},
35 },
36 },
37 },
38 0,
39 },
40 {
41 "foo.bar.baz",
42 hcl.Traversal{
43 hcl.TraverseRoot{
44 Name: "foo",
45 SrcRange: hcl.Range{
46 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},
47 End: hcl.Pos{Line: 1, Column: 4, Byte: 3},
48 },
49 },
50 hcl.TraverseAttr{
51 Name: "bar",
52 SrcRange: hcl.Range{
53 Start: hcl.Pos{Line: 1, Column: 4, Byte: 3},
54 End: hcl.Pos{Line: 1, Column: 8, Byte: 7},
55 },
56 },
57 hcl.TraverseAttr{
58 Name: "baz",
59 SrcRange: hcl.Range{
60 Start: hcl.Pos{Line: 1, Column: 8, Byte: 7},
61 End: hcl.Pos{Line: 1, Column: 12, Byte: 11},
62 },
63 },
64 },
65 0,
66 },
67 {
68 "foo[1]",
69 hcl.Traversal{
70 hcl.TraverseRoot{
71 Name: "foo",
72 SrcRange: hcl.Range{
73 Start: hcl.Pos{Line: 1, Column: 1, Byte: 0},

Callers

nothing calls this directly

Calls 5

ParseTraversalAbsFunction · 0.85
ParseTraversalPartialFunction · 0.85
RunMethod · 0.80
EqualMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected